如何编写Jenkins管道脚本来运行Selenium测试套件

t0ybt7op  于 2023-08-03  发布在  Jenkins
关注(0)|答案(1)|浏览(91)

我正在建立一个jenkins管道来运行我的selenium测试套件。我想知道如何编写管道脚本,可以 checkout 我的项目和运行我的回归测试套件。
我的项目只包含Selenium测试套件,这些测试套件在应用程序URL上运行。应用程序URL通过www.example.com提供application.properties
我的回归测试套件由所有测试套件组成。我想建立一个jenkins管道,当运行作业时,我想执行所有的测试。
我想知道流水线的不同阶段以及如何编写它。AuthenticationTest.java和BiographicInfoTest.java包含使用TestNg和selenium编写的实际测试。
我一直在关注这个link,但不知道从哪里开始。

application.properties
app_url =http://myservername:8090/MyProject/

regression-test.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Regression Test Suite" parallel="tests" thread-count="5">
    <listeners>
        <listener class-name="myproject.selenium.utils.CustomisedReports" />
    </listeners>
    
    <suite-files>
        <suite-file path="./checkUserAuthentication.xml"></suite-file>
        <suite-file path="./checkUserBiographicInformation.xml"></suite-file>
    </suite-files>  
</suite> <!-- Suite -->

checkUserAuthentication.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="User Authentication"> 
  <test name="User Authentication">
    <classes>    
      <class name="myproject.selenium.user.authentication.AuthenticationTest"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

checkUserBiographicInformation.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="User Biographic Information"> 
  <test name="User Biographic Information">
    <classes>    
      <class name="myproject.selenium.user.authentication.BiographicInfoTest"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

字符串

niwlg2el

niwlg2el1#

您需要在pipeline或docker(文件)中运行gradle测试

stage('tests'){
  steps{
    sh 'gradle test --tests my-test-cases.*'
  }
}

字符串
为了成功执行您的测试必须正确配置(依赖项、URL、地址、属性等)
对于构建环境,可以使用gradle tools plugindocker gradle image

相关问题