Why isn't my @BeforeClass method running?

后端 未结 5 1151
天涯浪人
天涯浪人 2020-12-05 13:00

I have the following code:

    @BeforeClass
    public static void setUpOnce() throws InterruptedException {
        fail(\"LOL\");
    }

A

5条回答
  •  生来不讨喜
    2020-12-05 13:29

    do NOT extend TestCase AND use annotations at the same time!
    If you need to create a test suite with annotations, use the RunWith annotation like:

    @RunWith(Suite.class)
    @Suite.SuiteClasses({ MyTests.class, OtherTest.class })
    public class AllTests {
        // empty
    }
    
    
    public class MyTests {  // no extends here
        @BeforeClass
        public static void setUpOnce() throws InterruptedException {
            ...
        @Test
        ...
    

    (by convention: class names with uppercase letter)

提交回复
热议问题