Various technical articles, IT-related tutorials, software information, and development journals
Friday, November 2, 2018
TestNG's assertEquals will iterate an iterable
Today I saw a confusing test failure message from TestNG. I was using assertEquals to see if two objects were the same and expected the check to use reference equality, since the objects' class didn't override equals. Instead there was a message about some other objects not being equal and an iterator differing at a certain position. Since I hadn't overriden equals to examine objects referred to, I was confused for a moment until I remembered that the class was iterable. Apparently TestNG checks for that and will do an item-by-item comparison if possible. To just check for reference equality, I switched to assertSame.
Labels:
misc
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment