这两个注释都在 testNG 中的 @test 之前运行,那么它们之间有什么区别。
检查下面的代码和输出
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class Test_BeforeTestAndBeforeMethod {
@BeforeTest
public void beforeTest()
{
System.out.println("beforeTest");
}
@BeforeMethod
public void beforeMethod()
{
System.out.println("\nbeforeMethod");
}
@Test
public void firstTest()
{
System.out.println("firstTest");
}
@Test
public void secondTest()
{
System.out.println("secondTest");
}
@Test
public void thirdTest()
{
System.out.println("thirdTest");
}
}
output:
beforeTest
beforeMethod
firstTest
beforeMethod
secondTest
beforeMethod
thirdTest
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)