1.引用testNG 包,版本自行选择
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.21</version>
</dependency>
2.编写testNG.xml文件
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="suiteOne" parallel="true" thread-count="2">
<test name="testCase1">
<groups>
<run>
<include name="testGroups"/>
<include name="testGroups2"/>
</run>
</groups>
<classes>
<class name="com.xinzf.CalculateMethodTest"/>
</classes>
</test>
</suite>
3.配置maven
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<!--<testFailureIgnore>true</testFailureIgnore>-->
<forkMode>never</forkMode>
<argLine>-Dfile.encoding=UTF-8</argLine>
<suiteXmlFiles>
<!--testng.xml文件位置-->
<suiteXmlFile>src/main/resources/testNG.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
4.创建测试类
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
* @Author: xinzhifu
* @Description:
*/
public class CalculateMethodTest {
@Test
public void testParam() {
Assert.assertEquals("1","2");
}
}
5.配置idea
"Run ---> EditConfgiuration"
执行测试用例,在项目目录中生成test-out文件,index.html即可显示测试报告
testNG 学习资料 https://www.jianshu.com/p/0d50965b938d