Previous: Test Logging, Up: Test Logging



4.9.1 XML Logging

The log can also be written in XML. The following functions define the interface for XML logs:

     
     void srunner_set_xml (SRunner *sr, const char *fname);
     int srunner_has_xml (SRunner *sr);
     const char *srunner_xml_fname (SRunner *sr);

The only thing you need to do to get XML output is call srunner_set_xml() before the tests are run. Here is an example of the same log output as before but in XML:

     
     <?xml version="1.0"?>
     <testsuites xmlns="http://check.sourceforge.net/ns">
       <datetime>2004-08-20 12:53:32</datetime>
       <suite>
         <title>S1</title>
         <test result="success">
           <path>.</path>
           <fn>ex_xml_output.c:8</fn>
           <id>test_pass</id>
           <description>Core</description>
           <message>Passed</message>
         </test>
         <test result="failure">
           <path>.</path>
           <fn>ex_xml_output.c:14</fn>
           <id>test_fail</id>
           <description>Core</description>
           <message>Failure</message>
         </test>
         <test result="error">
           <path>.</path>
           <fn>ex_xml_output.c:18</fn>
           <id>test_exit</id>
           <description>Core</description>
           <message>Early exit with return value 1</message>
         </test>
       </suite>
       <suite>
         <title>S2</title>
         <test result="success">
           <path>.</path>
           <fn>ex_xml_output.c:26</fn>
           <id>test_pass2</id>
           <description>Core</description>
           <message>Passed</message>
         </test>
       </suite>
       <duration>0.304875</duration>
     </testsuites>