TestNg1. 基本介绍注解介绍和如何让在maven中引用
1.更适合测试人员,有很多的套件。
maven中引用:
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
2.注解介绍:
package com.course.testng; import org.testng.annotations.*; public class BasicAnnotation { @BeforeClass public void beforeClass(){ System.out.println("BeforeClass类之前打印"); } @AfterClass public void afterClass(){ System.out.println("AfterClass类之后打印"); } @BeforeMethod public void beforeMethod(){ System.out.println("BeforeMethod方法之后打印出来"); } @AfterMethod public void afterMethod(){ System.out.println("AfterMethod方法之后打印出来"); } @BeforeSuite public void beforeSuite(){ System.out.println("BeforeSuite测试套件在类运行之前,一个套间里面可以有多个类"); } @AfterSuite public void afterSuite(){ System.out.println("AfterSuite测试套件在类运行之后"); } //最基本的注解,用来把方法标记为测试的一部分 @Test public void testCase1(){ System.out.println("这是测试用例1"); } @Test public void testCase2(){ System.out.println("这是测试用例2"); } }
结果: