Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[mdt-papyrus.dev] Usage of Assert.assertTrue & Assert.assertEquals() in JUnit tests

Hi All,

 

I just wanted to push a gentle reminder on the test framework. I am currently reviewing some contributions on gerrit, and especially some updates of the Junit tests on Papyrus.

 

When trying to see if a numeric result of a method is good compared to a reference value, it would be much better to rely on the method org.junit.Assert.assertEquals(String, int, int), rather than using the method org.junit.Assert.assertTrue(String, boolean) with something like Assert.assertTrue(“not equals”,int1 == int2).

If assertEquals(String, int, int) is used, the junit fails telling what was the expected, and what is the current result. In assertTrue(String, boolean) and ‘==’is used, we don’t know what was expected and the result, except if we run & debug the test again.

 

Thanks!

Rémi

 

-------------------------------------------------------

 

Rémi SCHNEKENBURGER

+33 (0)1 69 08 48 48

CEA Saclay Nano-INNOV

Institut CARNOT CEA LIST

 

Description : PapyrusLogo_SmallFormatwww.eclipse.org/papyrus

 


Back to the top