testng beforesuite 怎么用

2024-12-14 19:01:42
推荐回答(1个)
回答1:

一、在Eclipse中在线安装TestNG

打开Eclipse   Help ->Install New Software ,   然升明弊后Add   "http://beust.com/eclipse"

二、在Eclipse中离线安装Testng

1. 将槐闹解吵族压后的文件..\eclipse-testng离线包\features\org.testng.eclipse_6.9.9.201510270734文件夹放到eclipse--》features目录下

2. 将解压后的文件..\eclipse-testng离线包\plugins\org.testng.eclipse_6.9.8.201510130443文件夹放到 eclipse--》plugins目录下

3. 重启eclipse

4. 验证是否安装成功,file-->new-->other-->TestNg

三、TestNG最简单的测试

package TankLearn2.Learn;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.testng.annotations.Test;

public class TestNGLearn1 {

   @BeforeClass
   public void beforeClass() {
       System.out.println("this is before class");
   }

   @Test
   public void TestNgLearn() {
       System.out.println("this is TestNG test case");
   }

   @AfterClass
   public void afterClass() {
       System.out.println("this is after class");
   }
}

四、TestNG的基本注解