cancel
Showing results for 
Search instead for 
Did you mean: 

Why my assertion is failing

Contributor

Why my assertion is failing

As on the image you can see Mylist and CityList are same.

But at the assertion get failed.


10-17-2018 3-55-17 PM.png

3 REPLIES 3
Regular Contributor

Re: Why my assertion is failing

try to compare single item at once, hope you will find the error that way.

 

 


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" Smiley Happy

Thanks and Regards,
Himanshu Tayal
Community Hero

Re: Why my assertion is failing

Use in only to compare single items from a list. Use equals to compare the whole list, or assert that each item from the first list is in the second list.

 

def a = [1,2]
def b = [1,2,3]
def c = [[1,2],3]
def d = [1,2]

assert (a in c)
assert !(a in b)
a.each { assert it in b }
assert a == d
Contributor

Re: Why my assertion is failing

I was able to solve this issue by adding below aseertion.

 

log.info myList
log.info cityList
assert myList == cityList
assert cityList.equals(myList)
New Here?
Join us and watch the welcome video:
Watch the new Interview