Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

How do you use assertEquals JUnit testing for booleans and other objects besides strings and integers?

+6 votes
asked Oct 10 in CSC 285 (F17) by Brian Hinsberger (100 points)

3 Answers

+1 vote
I just had the import and instantiation for the booleans I was testing outside the proper method in the test class. The assertEqual method should work with all different objects, checking where you instantiate stuff is important!
answered Oct 10 by Brian Hinsberger (100 points)
+1 vote
I think that there are a lot of signature for you to use, types that have been implement such as set or list.

Or you can test your own type of object as long as you override the equal method.
answered Oct 11 by Dat Tran (100 points)
+1 vote
I am using assertTrue(object1.equals(object2));

assertFalse(object1.equals(falseObject));

I am sure I am not getting the full toolset, but if you need boolean checks this seems to be the way to go.
answered Oct 11 by Daniel Zwiener (100 points)
Also I found this: https://www.tutorialspoint.com/junit/junit_basic_usage.htm
It uses AssertEquals
...