Reputation: 93
My response looks as follows :
{
"data":[
{
"foo":bar1
"user_email":"[email protected]",
"user_id":1
},
{
"foo":bar2
"user_email":"[email protected]",
"user_id":1
}
]
}
* def DBOutput = #fetching values from DB
* match response.data[*].foo contains [DBOutput1[0][0],DBOutput1[1][0]]
DBOutput1 has data as follows : [["bar1"],["bar2"]]
This match fails, for some reasons value passed into the expected list in match statement is DBOutput1[0][0]
This is the error I am getting actual: ["bar1","bar2"], expected: 'DBOutput1[0][0]',
Upvotes: 1
Views: 39
Reputation: 93
I iterated over the DBoutput and stored them in a new array list. I then matched the response to the list and it worked.
Upvotes: 1
Reputation: 58088
You have some seriously malformed JSON in your example above. The below snippet works, just paste it into a new Scenario
:
* def response =
"""
{
"data":[
{
"foo": "bar1",
"user_email":"[email protected]",
"user_id":1
},
{
"foo": "bar2",
"user_email":"[email protected]",
"user_id":1
}
]
}
"""
* match response.data[*].foo contains ['bar1', 'bar2']
Now it is up to you to fix your test, without knowing what your DBOutput
is no one can help further.
Upvotes: 1