I am beginning with JUnit and do not understand the annotations @Test
and @BeforeClass
.
I have the following code:
public class Toto {
@BeforeClass
public static void setupOnce() {
final Thread thread = new Thread() {
public void run() {
Main.main(new String[]{"-arg1", "arg2"});
}
};
try {
thread.start();
} catch (Exception ex) {
}
}
Why @BeforeClass
? And what's the setupOnce()
and threads in this case?
Should we add @Test
before each Java test?
So if I have 30 Java tests, should I have @Test public void test()
in each Java file?