如何在Jenkins中使用Maven从多个套件中运行特定的TestNG套件

编程入门 行业动态 更新时间:2024-10-17 13:31:39
本文介绍了如何在Jenkins中使用Maven从多个套件中运行特定的TestNG套件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个带有3个TestNG套件和4个测试类的maven项目,我想在jenkins中运行一个特定的套件,我进行了很多搜索,但发现只有一个命令可以放入目标test -DsuiteXmlFile=Jquery.xml中以指定特定的套件,但是当我这样做,它也会同时运行所有其他套件.我在这里呆了很长时间,请引导我完成整个过程. 而且我还想知道是否可以进行任何设置,以便如果我选择运行一个套件,那么可以运行该套件的任何特定类. 我在这里附加了我的项目结构的图像,任何输入将不胜感激.谢谢:)

I have a maven project with 3 TestNG suites and 4 test classes, I want to run a specific suite in jenkins, I searched a lot but found only one command to put in goal test -DsuiteXmlFile=Jquery.xml to specify the particular suite but when I do this it runs all the other suites as well. I am stuck here for a long time, Please guide me through the process. And also I want to know whether there is any setting I can do so that if I select one suite to run, any particular class of that suite I can run. I have attached image of my project structure here, Any input would be appreciated. Thanks :)

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "testng/testng-1.0.dtd"> <suite name="WebGuru99"> <test thread-count="5" name="TestGuru99"> <classes> <class name="com.selenium.vivek.Example2.WebGuru99_1"/> <class name="com.selenium.vivek.Example2.WebGuru99_2"/> </classes> </test> <!-- Test --> </suite> <!-- Suite -->

Jquery.xml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "testng/testng-1.0.dtd"> <suite name="WebJquery"> <test thread-count="5" name="TestJquery"> <classes> <class name="com.selenium.vivek.Example2.WebJquery"/> </classes> </test> <!-- Test --> </suite> <!-- Suite -->

Rediff.xml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "testng/testng-1.0.dtd"> <suite name="WebRediff"> <test thread-count="5" name="TestRediff"> <classes> <class name="com.selenium.vivek.Example2.WebRediff"/> </classes> </test> <!-- Test --> </suite> <!-- Suite -->

Pom.xml

<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <configuration> <suiteXmlFiles> <suiteXmlFile>Suites/Guru99.xml</suiteXmlFile> <suiteXmlFile>Suites/Rediff.xml</suiteXmlFile> <suiteXmlFile>Suites/Jquery.xml</suiteXmlFile> </suiteXmlFiles> </configuration> </plugin> </plugins>

推荐答案

因此,我在这里没有找到任何答案,因此继续我的探索旅程,以解决该问题并找到解决方案.因此,对于任何面对此类问题的人,也可能会从中受益.

So, I didn't find any answers here, so continued my journey to explore what could be done to get around this issue and found out a solution. So for anyone who faces this kind of issue might as well get benefited.

在pom文件中使用<properties></properties>.添加一个标记,然后可以在通过maven目标运行时将其作为参数传递.

Use <properties></properties> in pom file. Add a tag which can be then passed as an argument while running through maven goal.

我在pom中添加了suiteFile作为标签,然后在<suiteXmlFile>中将其作为变量传递

I added 'suiteFile' as a tag in pom and then passed it in <suiteXmlFile> as a variable

<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <suiteFile></suiteFile> </properties> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <configuration> <suiteXmlFiles> <suiteXmlFile>${suiteFile}</suiteXmlFile> </suiteXmlFiles> </configuration> </plugin>

然后在詹金斯大学,我通过了clean test -DsuiteFile=Suites\Jquery.xml作为目标,并且仅运行该套件. 希望能帮助到某人:)

And then in jenkins, I passed clean test -DsuiteFile=Suites\Jquery.xml as goal and it ran only that suite. Hope that helps someone :)

更多推荐

如何在Jenkins中使用Maven从多个套件中运行特定的TestNG套件

本文发布于:2023-11-07 10:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566244.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:套件   多个   如何在   Maven   Jenkins

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!