我有一个示例JUnit
测试用例,它工作得非常好,但是我不确定它是如何开始执行的,因为它不包含 main 或任何 runner 类函数。谁能分享没有主要功能JUnit
的测试用例如何执行?
代码是:
import static org.junit.Assert.assertEquals;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
public class testJUnit {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
System.out.println("Before Class");
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
System.out.println("Tear Down After Class");
}
@Before
public void setUp() throws Exception {
System.out.println("Setup");
}
@After
public void tearDown() throws Exception {
System.out.println("Tear Down");
}
@Test
public void test() {
int a = 1;
assertEquals("Testing...", 1, a);
}
@Ignore
@Test
public void test1() {
int a = 156;
assertEquals("Testing...", 156, a);
}
}