用maven将TestNG框架代码打成jar包并执行测试-可持续集成
2018-01-12 10:41
323 查看
1.maven 依赖 TestNG:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
<scope>compile</scope>
</dependency>
注:<scope>compile</scope>或者默认不填,表示依赖打包到项目中。
2.<!-- maven test 执行testng.xml -->
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
3.<!-- maven 打依赖jar包 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.uiautotest.platformsys.JavaRunXml</mainClass>//执行主程序
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
4.testng.xml文件放入要执行的jar包中
cmd执行命令:
java -jar jar包名.jar
执行后 test-output 文件生成在 与 testng.xml 同目录中。
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
<scope>compile</scope>
</dependency>
注:<scope>compile</scope>或者默认不填,表示依赖打包到项目中。
2.<!-- maven test 执行testng.xml -->
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
3.<!-- maven 打依赖jar包 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.uiautotest.platformsys.JavaRunXml</mainClass>//执行主程序
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
4.testng.xml文件放入要执行的jar包中
cmd执行命令:
java -jar jar包名.jar
执行后 test-output 文件生成在 与 testng.xml 同目录中。
相关文章推荐
- maven编译不执行Juiit的测试代码
- Java+Selenium3框架设计准备篇6-TestNG执行测试方法依赖关系
- maven 将代码打成可执行jar包
- selenium的TestNG框架注解,测试集合,用例分组,依赖测试,特定顺序执行,跳过某个case执行,自定义日志,断言_06
- 持续集成:Jmeter+Maven+Jenkins自动化框架搭建(四):GitLab代码更新触发Jenkins自动构建
- maven编译不执行Juiit的测试代码
- 使用maven-shade-plugin构建可执行jar 解决junit4测试问题 maven项目
- java命令执行jar包(里面的main函数,无web.xml文件)的方式(包括依赖其它的jar包),使用Google-Guava Concurrent包里的Service框架,maven工程
- Spring4集成quartz,Maven打包为可执行jar或者war
- selenuim+testng集成ant和reportNG自动执行和发送测试报告
- 用maven搭建 testNG+PowerMock+Mockito测试框架
- Maven捆绑TestNG实现测试自动化执行、部署和调度
- 基于Jmeter+Maven+Jenkins持续集成接口测试框架
- TestNG方法测试及注意要点 代码及配置详解(解决testng方法不执行问题)
- 分布式服务框架dubbo-使用Maven构建Dubbo服务的可执行jar包(4)
- maven打成jar包,怎么跳过测试代码
- 接口测试框架开发(三):maven+restAssured+Excel(jxl)+testng+extentreports的接口自动化
- 基于Jmeter+Maven+Jenkins持续集成接口测试框架
- 集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery
- Groovy(java)+Spock+IDEA+maven+Jenkins+SVN+maven-surefire-plugin+maven-surefire-report-plugin/maven-antrun-extended-plugin集成接口测试框架