как запустить отдельные тестовые случаи из jenkins, передав параметры в testng.xml через pom.xml - PullRequest
0 голосов
/ 23 февраля 2019

Я хочу запускать тестовые случаи в зависимости от переменных, переданных от jenkins, например, если я выберу TestCaseForHistoryPage при выборе из jenkins, он должен запускаться только.

Мой testng, xml выглядит так:

<test name="TestCaseForInlineRedemption">
      <classes>
        <class name="test_cases.TestCaseForInlineRedemption">
      </class>
    </classes>
  </test> <!-- Test -->
  <test name="TestCaseForHistoryPage">
      <classes>
        <class name="test_cases.TestCaseForHistoryPage">
      </class>
    </classes>
  </test>


And pom like:

<plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>

      </plugin>
     <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
            <configuration>
             <systemPropertyVariables>
             <testnames>${Dtest}</testnames>
            <country>${Dcountry}</country>
            <environment>${Denvironment}</environment>
          </systemPropertyVariables>
                    <testFailureIgnore>true</testFailureIgnore>
                <suiteXmlFiles>
                <!-- TestNG suite XML files -->             
                    <suiteXmlFile>testng.xml</suiteXmlFile>
                </suiteXmlFiles>                
                 <systemProperties>
            <property>          

             **<test>${Dtest}</test>** 
          </property>
         </systemProperties> 
            </configuration>
    </plugin>

Я хочу передать $ {Dtest} от Дженкинса для тестирования через pom.

Может кто-нибудь помочь с этим?

1 Ответ

0 голосов
/ 23 февраля 2019

Option-1:

Вы можете проверить этот плагин для запуска выбранных тестовых случаев. Плагин выбора тестов

Option-2:

Создайте еще один файл HistoryPage.xml для тестовых случаев TestCaseForHistoryPage.Используйте динамическое имя файла XML в «maven-surefire-plugin», как упомянуто ниже.

    <configuration>

            <suiteXmlFiles>

                <!-- TestNG suite XML files -->
             <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>

            </suiteXmlFiles>


    </configuration>

Теперь вы можете использовать его для запуска через maven

mvn clean test -Dsurefire.suiteXmlFiles=fileName.xml

В Jenkins вы можете создавать задания с помощьюОпция «построить с параметрами» и создать строковый параметр. Теперь вы можете передать этот параметр в Jenkins.

...