Can some one please explain why my assertion is failing
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can some one please explain why my assertion is failing
As on the image ActualschoolList and ExpectedchoolList are same.(you can see it as a log )
But when I try to assert it its giving me an error.
How to fix this.
Both variables are having somthing similar to this "[]"
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think it is because you variable "ActualschoolList" is an empty Groovy List object, but your variable "ExpectedchoolList" is the literal string "[]" these are two different things, thus the assertion fails. If you are expecting an emty list, try defining "ExpectedchoolList" as follows:
def ExpectedchoolList = []
See the following page for more info on working with lists:
http://docs.groovy-lang.org/next/html/documentation/working-with-collections.html#Collections-Lists
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @chathurad,
Instead of doing [] == [], match the size if you don't want to assert on the items inside your List.
try using
assert (actualList.size() == expectedList.size()) : "Size not equal"
Click "Accept as Solution" if my answer has helped, and remember to give "kudos" 🙂
Regards,
Himanshu Tayal
Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓
Thanks and Regards,
Himanshu Tayal
