testNG注释运行顺序

来源:互联网 发布:易语言小游戏源码 编辑:程序博客网 时间:2024/05/18 08:20

TestNG

import org.testng.annotations.Test;import org.testng.annotations.BeforeMethod;import org.testng.annotations.AfterMethod;import org.testng.annotations.BeforeClass;import org.testng.annotations.AfterClass;import org.testng.annotations.BeforeTest;import org.testng.annotations.AfterTest;public class NewTest {  @Test  public void f1() {  System.out.println("test1");  }    @Test  public void f2() {  System.out.println("test2");  }  @BeforeMethod  public void beforeMethod() {  System.out.println("before method");  }  @AfterMethod  public void afterMethod() {  System.out.println("after method");  }  @BeforeClass  public void beforeClass() {  System.out.println("before classs");  }  @AfterClass  public void afterClass() {  System.out.println("after classs");  }  @BeforeTest  public void beforeTest() {  System.out.println("before test");  }  @AfterTest  public void afterTest() {  System.out.println("after test");  }}

运行结果为:

before test
before classs
before method
test1
after method
before method
test2
after method
after classs
after test


0 0
原创粉丝点击