您的位置:首页 > 编程语言

用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 同目录中。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐