首页 文章

如何在Jenkins中运行Selenium测试

提问于
浏览
0

我想在Jenkins中运行我的Selenium Webdriver Maven测试 . 我已经按照教程:https://www.guru99.com/maven-jenkins-with-selenium-complete-tutorial.htmlhttps://www.safaribooksonline.com/library/view/jenkins-the-definitive/9781449311155/ch04s06.html但是现在,我想运行我用Selenium Webdriver用Eclipse编写的数百个测试中的每一个 .

我使用Maven来创建testng.xml(我有我的Maven项目,可以在同一个执行中执行测试列表) . 我使用Eclipse编写Java来在Selenium Webdriver中创建测试 . 我使用github导入测试 .

我告诉你我的github项目...我不知道如何访问不同的文件夹来执行每个testng.xml文件,对不起,我在这里很新 .

enter image description here

enter image description here

enter image description here

有人可以帮我解决这个问题吗?

非常感谢!!!!

1 回答

  • 0
    • 创建一个自由式Jenkins作业,然后转到作业的配置页面,并在 Source Code Management 部分添加您保存TestNG测试的Git仓库的URL . 这将有助于将测试从存储库带到您的工作区 .

    • 然后转到 Build 部分并选择 Execute windows batch script if,然后添加以下脚本:

    java -cp ".;/path/to/testng-x.x.x.jar;/path/to/jcommander-x.xx.jar;/path/to/test-classes" org.testng.TestNG /path/to/test.xml

    对于 Linux ,在“构建”步骤中使用以下脚本和 Execute shell

    cd /path/to/test.xml java -cp "/path/to/testng-x.x.x.jar:/path/to/bin" org.testng.TestNG testng.xml

    其中 /bin 文件夹包含TestNG测试的已编译代码 .

    • 然后保存作业并运行构建以执行TestNG测试用例 .

    注意:您可以在 .m2 文件夹中找到所需的JAR文件 .

相关问题