dimanche 1 juillet 2018

Test if an array contains an element from another array with hamcrest

I actually have two types of data :

a = ["1", "2", "3", "3", "5"]
b = ["7", "2"]

given()
       .header("Content-Type", "application/json").
when()
       .post(this.url).
then()
       .statusCode(200)
       .contentType("application/json")
       .body(myPathToData, everyItem(haveOneOrMoreElementFrom(a)));

I would like to test, with hamcrest in my body response after my rest-assured request, if b (element received) contains one or more element from a (haveOneOrMoreElementFrom in my example).

Is it also possible to make a function in my body response??

Thanks for your answers.

Aucun commentaire:

Enregistrer un commentaire