I understand the importance of testing and unit testing in general, but is JUnit used everywhere in the real world, and what are the advantages of using it over the โmanualโ testing method? That is, why use the JUnit Test:
public class MyTest extends TestCase
{
public void testSomething()
{
assertTrue(someCondition);
assertTrue(manyOtherConditions);
}
}
compared to some kind of lightweight user debugging device
public class MyTest
{
public static void testSomething()
{
MyDebugUtility.println(someCondition);
MyDebugUtility.println(expectedCondition);
}
}
and check the return values โโyourself? In any case, you will need to make a comparison between the conditions and with Unit Tests, it seems that it is VERY easy to miss in your test code (as I did) and wonder why your class does not work when your real error accidentally typed assertTrue , not assertFalse.
Even if you need simple logic functionality that makes JUnit taller
public class MyTest
{
public static void testSomething()
{
if(condition1)
MyDebugUtility.println("Passed condition1");
else
MyDebugUtility.doError();
}
}
JUnit, ? , , .