1
votes

I have the following Test class...

@RunWith(JUnit4.class)
public class AdminSpecTest extends BaseTest{
    @BeforeClass
    public static void getLogin(){
        System.out.println("getLogin");
        ...
    }
    @Test
    public void testAdminPage(){
        System.out.println("testAdmin");
        ...
    }
}

When I try to create a JUnit sampler in JMeter I run the test and it fails. In the terminal window I see...

testAdmin

but there is no getLogin. Why isn't BeforeClass getting called? Can I get this to happen?

1

1 Answers

1
votes

Accoding to JMeter's JUnit you can use @Before instead for setup before test executes.

The following JUnit4 annotations are recognised:

@Before treated the same as setUp() in JUnit3

@BeforeClass, @AfterClass treated as test methods so they can be run independently as required