Forum Discussion

hkoestin's avatar
hkoestin
Occasional Contributor
7 years ago

Export Logs as XML or JSON format

Dear all,

 

I am trying to accomplish the following: in a TFS build definition, I want to execute TC tests using the Run Functional Tests task on a remote (distributed) test agent and afterwards parse the log output to further process that data (especially the data about every single test-item of the suite). Background is, that the test results published by TC do not include all single test items from TC suites and projects, but only one entry for each test project in the suite. And only if you open up the entry for the test project in TFS, you will see the attached .mht file, which then contains all information about all test items of that project.

 

I actually thought that I can use the /exportToXmlAlso flag for running TC, but this does not produce an XML at all.

No matter if I start TC using the command line and provide that parameter or if I run TC using the MSBuild task, it somehow just gets ignored. Also for the TFS "Run functional Tests" task, I do not know how to supply that parameter. I also tried to add an event handler for the OnTestStop event for the general events and use the Log.SaveResultAs() method to write a proper XML file, but that did not work either, as I only can write for the current test item and not for all the test items in a suite.

 

My used documentation so far:

Actually I would expect TC to export the logs in the formats as specified here:

https://support.smartbear.com/testcomplete/docs/testing-with/log/working-with/exporting/structure.html

 

All I get so far is the some weird TC internal formats (when using the .tcLogX extension for the log file) or a .MHT file (when using the .mht extension for the log file) and the RootLogData.dat file in the Log folder of the TC suite, which just contains a weird XML structure, having <Node> elements nested allover and which does not seem to be really "parsable".

 

How can I instruct TC from TC/MSBuild/TFS-Task to export the logs in a nice XML or JSON format?

Any help regarding this topic is very much welcome!!! 

 

9 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Are you coupling the /ExportToXMLAlso command line parameter with the /ExportLog: command line?  They have to work together.  You can't have the first without the second.

    • hkoestin's avatar
      hkoestin
      Occasional Contributor

      Hey Robert

       

      Thanks for your reply. 

       

      In fact, I am using the following PS1 script to start the process:

      Start-Process TestComplete -ArgumentList "$project /run /exportLog:$log /exportLogToXMLAlso /errorLog:$errorLog /Exit /ns" -Wait

      However, even if I start it from an ordinary command prompt, no XML results are produced. I only get the RootLogData.dat file generated, which is XML, but not really structured nor according to the documentation. It is pretty hard to parse, as there is only a Nodes/Node collection in there.

       

       

      So, the following things tried and no XML results showing up:

      * PS1 scripts

      * CMD (batch) scripts

      * TFS run functional tests with additional arguments in .runsettings file

       

      Only thing working so far: right-clicking the logs in TC itself and clicking on "Export to ..." + then selecting the XML option with unpacked format etc.

       

      BTW: am using version 12.31.1833.7

       

      Thanks again for any advice/help with that topic!

      • hkoestin's avatar
        hkoestin
        Occasional Contributor

        I would also be very happy with an ordinary JSON file. Doesn't really matter actually, if it is XML or JSON. Just parsable and in the format as given by the documentation.