Akshay Maldhure
Akshay Maldhure

Reputation: 857

Jenkins TestNG plugin does not fetch results from the test-results.xml file

In my project workspace, the test-results.xml file exists inside the target\surefire-reports\testng-results.xml directory. But Jenkins fails to read the XML file and gives below error on console.

TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **\target\surefire-reports\testng-results.xml
Did not find any matching files.

To ensure the file isn't too old, I had checked that the test-results.xml (and other files) belong to the latest test run. The Jenkins server is running on Ubuntu 14.04 LTS.

I'm running my tests in this manner: My project root directory has a run_tests.sh script which looks like this:

#!/bin/bash

if [ "$1" = "" ]; then
    echo "Please provide a valid suite XML file name."
else
    mvn clean
    mvn compile
    mvn clean test -Dsurefire.suiteXmlFiles="$1"
fi

I just pass the suite XML file name as a parameter to this script in Jenkins (execute shell).

Please help.

Upvotes: 0

Views: 7349

Answers (5)

HARSH CHOKSHI
HARSH CHOKSHI

Reputation: 16

I agree with Krishnan Mahadevan usage of '\' instead of '/' while providing the path for TestNG Report also solved my problem.

Extremely important thing to note here:

When providing path for Root POM in the build section '\' is used

C:\Users\harsh\eclipse-workspace\ProjTwo3\pom.xml

When providing path for TestNG XML report pattern in Publish TestNG Result section '/' is used

C:/Users/harsh/eclipse-workspace/ProjTwo3/target/surefire-reports/testng-results.xml

Console Output:

channel stopped
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern:
C:/Users/harsh/eclipse-workspace/ProjTwo3/target/surefire-reports/testng-results.xml
Saving reports...
Processing 'C:\Users\harsh.jenkins\jobs\MyApplication\builds\12\testng\testng-results.xml'
11.688312% of tests failed, which exceeded threshold of 0%. Marking build as UNSTABLE

Upvotes: 0

VSR
VSR

Reputation: 33

I found the solution for this.

  1. Go to Configure of your Job
  2. in General Tab, you may find
    Advanced Button, Click on this
  3. Check the check box of "Use custom workspace", under this you see the Directory text box, here you copy your Selenium Workspace Folder, for example mine is
    "E:\eclipse\eclipse-workspace\WebDriveTest\"
  4. Scroll down the page under the Post-build Actions, Publish TestNG Results, TestNG XML report pattern : give like this
    "**/target/surefire-reports/testng-results.xml" (check this path in the same workspace).

I hope this will help you!.

Upvotes: 2

Reed_Xia
Reed_Xia

Reputation: 1442

Please see my answer in another post here, it should be very clear.

In short, it is caused by the current directory was changed to the default Jenkins workspace, you need set your custom workspace in the Job's Config.

Upvotes: 0

Akshay Maldhure
Akshay Maldhure

Reputation: 857

Krishnan, in the testng-users Google Group, pointed out that it could be an issue with my Jenkins project workspace, and it was the same.

I changed the default workspace in my Jenkins project.

So I've added the path "$HOME/myWorkspace/myProject/" in my Jenkins project workspace, and "**/target/surefire-reports/testng-results.xml" in my TestNG setting in the same Jenkins project, and it works!

Thank you Krishan for your help.

Upvotes: 0

Krishnan Mahadevan
Krishnan Mahadevan

Reputation: 14736

You should be using / instead of \ (since you mentioned that your Jenkins is running on a UNIX box)

Upvotes: 1

Related Questions