[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Originally posted by Jeanne Boyarsky:
Gregg,
I don't follow what you are asking for. The following checks objects are comparable. I suspect you means something else though.
assertEquals("comparable", 0, obj1.compareTo(obj2));
Originally posted by Gregg Bolinger:
I was looking at the API. How do you know to put "comparable" in for the message? What are the other message options?
Originally posted by bart zagers:
The message is just a reference that is printed when the test fails. There are no special options and it has nothing to do with the actual test.
Or am I misinterpreting the question?
Originally posted by Gregg Bolinger:
Assert.assertTrue(obj1.compareTo(obj2) == 0);
Is there any advantage/disadvantage to this over Jeanne's suggestion?
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Originally posted by Lasse Koskela:
When Jeanne's assertion fails she hears "AssertionFailedError: comparable".
[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
Note that the tests suggested so far don't really fully test that compareTo is working as expected - for that you needed to test different scenarios.
[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |