最近尝试了通过jenkins构建,通过执行testNG的XML文件调用测试类,并将外部参数传递给testNG,过程比较简单。
一、配置maven
配置2项,一个是要执行的xml文件,变量名xmlFileName,一个是要传递的参数cookie。
<build>
<plugins>
<plugin>
<!--该插件是解决命令下执行mvn test指定testng xxx.xml 文件 的配置-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<!--为了解决在jenkins maven执行test 报告乱码问题,编码格式设置为UTF-8-->
<argLine>-Dfile.encoding=UTF-8</argLine>
<encoding>UTF-8</encoding>
<!--动态指定执行的xml文件。${project.basedir}项目目录,${xmlFileName}maven文件-->
<suiteXmlFiles>
<suiteXmlFile>${project.bas