JUnit Testing - What makes it so useful for manual testing?

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(); //handle however you want
    }
}

JUnit, ? , , .

+3
4

- , - . :

  • 1000 ? , ", ", ?

  • script . , , ( , ).

  • . , , , , .

  • seand, xUnit , - IDE , , Hudson, / , , . , - , / , - , .

+16

, JUnit, NUnit .., , . , JUnit , setUp(), tearDown() .. .

JUnit, , IDE.

, . JUnit- . , ?

+1

, . ( , CI, ..).

+1

JUnit can be integrated into a continuous integration process with virtually no effort, so that if someone breaks the assembly, the whole team knows about it in minutes. This feature alone is worth using.

Of course, there are other useful features in another answer. JUnit is a wheel that you really don't want to invent.

If you have something against JUnit, try TestNG - it might work better for you.

0
source

Source: https://habr.com/ru/post/1794633/


All Articles