junit4 beforeClass方法每次都执行
不是说beforeClass方法只会执行一次吗?怎么他跟before或after的方法一样,每次都执行啊?
看测试代码:
import org.junit.After;import org.junit.AfterClass;import org.junit.Before;import org.junit.BeforeClass;import org.junit.Test;public class JustTest { @BeforeClass public static void beforeClass() { System.out.println("before class"); } @Before public void before() { System.out.println("before"); } @Test public void test() { System.out.println("test"); } @Test public void test2() { System.out.println("test2"); } @After public void after() { System.out.println("after"); } @AfterClass public static void afterClass() { System.out.println("after class"); } @Before public void beforeAgain() { System.out.println("before again"); }}