Forum Discussion

Felixg's avatar
Felixg
Occasional Contributor
4 years ago
Solved

Log.SaveResultsAs() do not work for the LogFormat lsJUnit

Hi everyone,

 

I would like to export JUnit report to see my summary reports in Jenkins.

Of course I read the Log.SaveResultsAs() function documentation, Viewing TestComplete Test Results in Jenkins and also Exporting Test Results , and the related documentations.

 

I want to export my test summary from my scripts using

Log.SaveResultsAs("C:\\Temporary jenkins workspace with spaces\\exports\\results.xml", lsJUnit, True, lesFull)

But it always returns "False", and the summary report is not exported. However, I am not doing something very complicated, and I have just called a function as it is given in the documentation as an example.

 

I also export logs with "lsZip" and "lsPackedHTML log formats with the same call, just adjusting the file name (and extension of course), and in that cases it works correctly.

 

Can you confirm if it is realy a bug of the Log.SaveResultsAs() function or if there are some specific things to do that are not written in the documentation please ?

 

PS: Why do I not use the /ExportSummary command line argument ?

  • Because when you configure a Jenkins job to publish JUnit report you have to give a relative path to the workspace.
  • Whereas the /ExportSummary argument expects an absolute path, the Jenkins workspace depends on the job name, so we can not use the command line argument because it is to heavy to edit the command line argument value each time we edit the job name (we use the job name as a test run title, so we edit it sometimes).
  • Moreover we have one job per PJS, deployed from a job template, so the commande line argument value has to be set for each job.
  • And in the /ExportSummary command line argument value we can not use environment variables, like the %WORKSPACE% variable which holds the running Jenkins.
  • Ok even if the Log.SaveResultsAs() function does not work with lsJUnit LogFormat, due to you last answer I found the way to use the command line argument /ExportSummary through the TestComplete Jenkins pluggin.

    Indeed, there were several tricky points. So when you go to the plugin configuration in your job, you click on "settings", and in the command line arguments you put :

    "/ExportSummary:${WORKSPACE}\results.xml"

    The tricky points are :

    • Even if the Jenkins server, and the slave agent, run on a Windows machine, use the UNIX syntax ${WORKSPACE} and not %WORKSPACE% (even if you use "\" and not "/" as path delimiter ... so UNIX syntax for environment variables, Windows syntax for others)
    • The quotes should include the argument also : "/ExportSummary:${WORKSPACE}\results.xml" and not /ExportSummary:"${WORKSPACE}\results.xml"

    Then you can specified in the post build step to publish JUnit report giving the following path : results.xml

     

    Thanks all for your answers

6 Replies

  • for the last two arguments of the log.saveresultas method, have you tried

    1) lower case "t" for true

    2) using the integer codes (aka 0,1, or 2) instead of lesFull, lesCurrentProject, etc...

     

    I'm assuming that the arguments are in the wrong format if the other operations like slpacker and etc are working but not this one when called on individually.

    • Felixg's avatar
      Felixg
      Occasional Contributor

      Hi hkim5 , Ihave tried what you suggested, I replaced lsJUnit by 5 and lesFull by 0, I tried with True and False (I forgot to precise in my first message that we are in Python) for the third parameter, and any summary report is generated.

      • hkim5's avatar
        hkim5
        Staff

        Felixg 

        so does it look like this: 

        Log.SaveResultsAs(Project.ConfigPath + "\\MHT_Files\\" + "results.xml", lsJUnit, true, 0)

        although, given that we are saving visualizer images, and we are saving in xml format, the last two arguments are not needed (as they are by default set to true and 0) so the above code would look more like  

        Log.SaveResultsAs(Project.ConfigPath + "\\MHT_Files\\" + "results.xml", lsJUnit)

         

        Then you should get your Junit xml results file in the directory that you wanted (since its project.configpath, if you are running it via jenkins, you'd find it in ${WORKSPACE}\MHT_Files\results.xml (if we use the code above)