@BeforeClass 在 IntelliJ 中根本没有 运行

@BeforeClass doesn't run at all in IntelliJ

我写了这段代码:

  UserManager userManager = new UserManager(); 

    @BeforeClass
    public static void tryi (){
        System.out.println("WooooooHOOOO");
    }

    @BeforeMethod 
    public void setup() {
        System.out.println("zdravo"); 
    }

    @AfterMethod(alwaysRun = true) //AfterClass se izvrshuva samo ednash za ovaa klasa na kraj a ne posle sekoj @Test
   
        System.out.println("cao");
    }


    @Test(description = " Verify that addUSer method returns true when successful")
    public void aTest1() {
        System.out.println("This is test 1");
    }

    @Test(timeOut = 500) // not enough time - will fail
    public void cTest2() {
        System.out.println("This is test 2");
    }

    @Test(enabled = false)
   nad class vazi za site testovi
    public void bTest3() {
        System.out.println("This is test 3");
    }


    @Test(priority = 1) //davame prioritet prv da se izvrshi
    public void successfulAddUserReturnsTrue() {
        //Arrange
        // UserManager userManager = new UserManager();
        //Act
        boolean result = userManager.addUser("john@email.com");
        //Assert
        Assert.assertTrue(result); 
    }

    @Test
    public void getUserReturnsExistingSavedUser() {
        //Arrange
        //UserManager userManager = new UserManager();
        userManager.addUser("john@email.com");
        //Act
        String user = userManager.getUser("john@email.com");
        //Assert
        Assert.assertEquals(user, "john@email.com");
    }

    @Test
    public void getNonExistingUserReturnsNull() {
        //Arrange
        //UserManager userManager = new UserManager();
        //Act
        String user = userManager.getUser("john@email.com");
        //Assert
        Assert.assertNull(user, "The method should return null if it doesn't find a user");
    }
}

现在当我 运行 测试时,一切正常,除了 @BeforeClass 不 运行 并且它没有显示在控制台中。

这是我得到的回复:

zdravo
This is test 1
cao
zdravo
This is test 2
cao
zdravo
cao
zdravo
cao
zdravo
cao

============================================= == 默认套件 总测试 运行:5,通过:5,失败:0,跳过:0

进程已完成,退出代码为 0

我通过添加这个导入解决了它:

进口org.testng.annotations.BeforeMethod