1. The reference testNG package, version choose
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.21</version>
</dependency>
2. Write testNG.xml file
<?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. Configure 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. Create a test class
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. Configuration idea
"Run ---> EditConfgiuration"
Execute test cases generated in the project directory test-out file, index.html to display the test report
testNG learning materials https://www.jianshu.com/p/0d50965b938d