Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Multi AssertEquals  RSS feed

 
Greenhorn
Posts: 22
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I am currently is writing an automated test though I am not sure how to handle multiple AssertEquals.

This is my code

if following statements below all of them are true
then print ("test")






Any ideas how to do this nice and smooth?

Thank you in advance
Regards

Xsi
 
Xsi jadu
Greenhorn
Posts: 22
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:This discussion would fit better in our testing forum. Moving.



I don't agree since its java development I am sure I get more answers in java section.... regardless its for test purpose...
 
Bartender
Posts: 9494
184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by doing it "nice and smooth"?

What's wrong with what you have now?
 
Ranch Hand
Posts: 239
12
Eclipse IDE IntelliJ IDE Java Scala Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One alternative might be to implement an equals() (or deepEquals?) method in RumbaLabel that compares all the fields you care about and just check that partnr is equal to an instance of RumbaLabel with those values. The problem with such an approach, though, is that it would move visibility of what exactly is different out of the test, so I wouldn't recommend it.
 
author & internet detective
Posts: 38917
686
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recommend using the optional string parameter. That way you know which field is wrong without having to go into the code.

Also, consider using assert softly so you can see all of the assertion failures in one go.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!