47

I'm beginner for "Jenkins" and following this tutorial.

At the Sixth step I got below error.

xcodebuild: error: Scheme JenkinsTest is not currently configured for the test action.

Build step 'Xcode' marked build as failure Recording test results ERROR: Step ‘Publish JUnit test result report’ failed: No test report files were found. Configuration error? Finished: FAILURE

In the Test report XMLs I did set "test-reports/.*xml"

I tried to find my solution and also many questions are founded on SO like same issue I have too but did not get solution.

I have some confusion, Is .xml file automatically generated by "Jenkins" or First we manually need to add .xml file ?

In short guide me on right direction based on above error.

Community
  • 1
  • 1
iPatel
  • 46,010
  • 16
  • 115
  • 137
  • Does the `test-reports` directory exist (in Jenkins workspace)? I can not test in the moment, but I _think_ it has another name on our system. – shallowThought Apr 03 '17 at 07:48
  • @shallowThought - Yes its exist. – iPatel Apr 03 '17 at 08:25
  • Have you solved the problem? I am stuck with the same issue. – rokridi Feb 09 '18 at 17:01
  • Did you find the solution, Coz I am having the same issue? Do we need to create `.xml` file manually or let Jenkins create it. – Rajat jain Apr 03 '19 at 11:41
  • For the 'not configured for the test action' error, see this other question. without the project being properly configured for testing, you will not end up with a results file. https://stackoverflow.com/questions/30481630/xcode-project-scheme-is-not-currently-configured-for-the-test-action – Scriptable Feb 13 '20 at 09:00

9 Answers9

39

You can also enable the 'allowEmptyResults' option so that the junit plugin won't throw an exception when it doesn't find test results.

This way it doesn't matter if the 'test-results' directory exists.

junit allowEmptyResults: true, testResults: '**/test-results/*.xml'
Jay Prall
  • 5,295
  • 5
  • 49
  • 79
18

First make sure junit.xml is getting generated after the test run.

Jenkins job at times cannot see past the current workspace. so it is always a good idea to copy the reports back to the current workspace before using it.

    cd <path to report>
    cp *.xml $WORKSPACE

Now the jenkins should pick-up the report. Note: The config may show error first(since it cannot find the xml file in workspace) but after a build this should go away and also the result should get recorded

  • I am on aws linux instance # junit MobaXterm X11 proxy: Unsupported authorisation protocol Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using 'localhost:11.0' as the value of the DISPLAY variable. – Ashish Karpe Jul 03 '17 at 11:06
  • 4
    I was having the same issue and copying the xml file to the root of the workspace resolved it for me. I had been running "junit " instead, which wasn't working. I do not understand why this fixes it, however. Can you explain this statement more: "Jenkins job at times cannot see past the current workspace. so it is always a good idea to copy the reports back to the current workspace before using it." – gregdferrell Jul 03 '18 at 14:43
10

I'm using nosetest (python) to generate an xUnit compatible file and I was getting:

ERROR: No test report files were found. Configuration error?

I was using junit plugin as:

junit "test-results-unit.xml"

junit seems to add WORKSPACE directory by default so using the full PATH to the file wouldn't work either. I created symlink from the resulting file to the WORKSPACE directory to make it work:

  sh 'ln -s tests/test-results-unit.xml $WORKSPACE'
  junit "test-results-unit.xml"
alfredocambera
  • 3,155
  • 34
  • 29
  • I am also getting same error, tried the approach suggested by you but no luck. Could you please advise if any other changes I need to make – Gaurav Parek Sep 08 '21 at 12:05
  • @GauravParek try finding the `test-results-unit.xml` file first by running `ls` or `find`, then create the symlink to the correct path – alfredocambera Sep 13 '21 at 12:35
5

Other answers suggest copying the files to the workspace directory, but for me simply changing the path to start with '**' seemed to solve the issue

junit '**/test-reports/*.xml'

The Jenkins junit plugin page says that you need to "specify the path to JUnit XML files in the Ant glob syntax". I've not dug into the full details of what this means, but starting the path with '**' was enough to get it working for me.

ClemFandango
  • 51
  • 1
  • 1
3

Thanks @Acid, it really helped me. First, copy the module/build/test-results to workspace directory

cp -r app/build/test-results $WORKSPACE/test-results

And then I used this wildcard path

**/test-results/**/*.xml
Pedro Romão
  • 2,285
  • 28
  • 22
1

How about:

junit allowEmptyResults: true, testResults: "${WORKSPACE}/test-results/*.xml"

or just:

junit "${WORKSPACE}/test-results/*.xml"
Dmitri Sologoubenko
  • 2,909
  • 1
  • 23
  • 27
0

I had the same problem and my test report file name got changed due to an upgrade in scala version,

Hence I have to change from,

junit '/myworkspace/target/myreport.xml'

to

junit '/myworkspace/target/TEST-myreport.xml'
Praveen
  • 1,791
  • 3
  • 20
  • 33
0

You have to find the path where your test reports are saved in your .jenkins workspace:

/Users/<USERNAME/>/.jenkins/workspace/<PROJECT/>/target/surefire-reports/*.xml

to find the folder type in your terminal:

.jenkins

then

open .
sFritsch09
  • 424
  • 4
  • 10
-1

I have faced same issue and find that i have used jococo instead of jacoco in my Jenkins file.

post{
              always{
                junit 'target/surefire-reports/*.xml'
                jacoco execPattern: 'target/jacoco.exec'
                
              }
            }