Form above explanation it seems that -.xml gets deleted when you re- your tests in Post task under , because when you run “mvn clean” it will delete the target folder where failed-.xml was present.
To verify this you need to access the Jenkins workspace, but your software company might not have the access to it.

Further follow these steps they will solve the issue:

First your pom should be configurable to run the tests from command line:

<plugin>
    <groupId>org.apache..plugins</groupId>
    <artifactId>-surefire-plugin</artifactId>
    <version>2.19.1</version>
    <configuration>
      <forkCount>0</forkCount>
      <suiteXmlFiles>
        <suiteXmlFile>src//resources/${suiteXmlFile}</suiteXmlFile>
      </suiteXmlFiles>
    </configuration>
  </plugin>

Then configure jenkins for the Post build(which is you already doing) to run the failed-testng.xml.

But first you have to copy/move the failed-testng.xml to from target folder to any other folder within framework(except target and test-output folder, because these folders gets deleted when you run the command “mvn clean”).

Below is the Maven plugin to copy/move file from one location to another location:

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.0.1</version>
    <executions>
      <execution>
        <id>copy-resources</id>
        <!-- here the phase you need -->
        <phase>validate</phase>
        <goals>
          <goal>copy-resources</goal>
        </goals>
        <configuration>
          <outputDirectory>${basedir}/target/failed-testng.xml</outputDirectory>
          <resources>          
            <resource>
              <directory>src/</directory>
              <filtering>true</filtering>
            </resource>
          </resources>              
        </configuration>            
      </execution>
    </executions>
  </plugin>

Note: This plugin must be executed after the tests execution.



Source link https://sqa.stackexchange.com/questions/10463/how-to-run-testng-failed-test--in-jenkins-for-maven-

LEAVE A REPLY

Please enter your comment!
Please enter your name here