XmlOutputter:write user defined mesgs in XML?

Help
2006-10-26
2013-04-22
  • Arti Gujare
    Arti Gujare
    2006-10-26

    Dear All,

    I am using CPPUnit::XmlOutputter to write the unit test results to an XML file.
    The program works as expected and I can see the test results in the xml file.
    But I also want to add intermediate results and user defined messages in the same xml result file.
    How do I do that in my Test function?
    // my code is
    main()
    {
            CppUnit::TextTestRunner runner;
        std::ofstream outputFile("testResults.xml");
        CppUnit::XmlOutputter* outputter = new CppUnit::XmlOutputter( &runner.result(),
            outputFile );   
        runner.setOutputter(outputter);

        runner.addTest(MyTestClass::suite());
            runner.run();
    }

    // MyTestClass is derived from CppUnit::TestFixture and uses CPPUNIT_TEST_SUITE macros.
    MyTestClass::Test()
    {
    // I need to write the progress status to the output xml file while the test is runnin
    }

    /////

    Thanks a ton,
    Arti gujare

     
    • Felix Deutsch
      Felix Deutsch
      2006-10-28

      Use the approach similar to the one suggested by the cppunit maintainer for associating test descriptions with testcases:
      http://permalink.gmane.org/gmane.comp.lib.cppunit.devel/176

       
    • michelleb
      michelleb
      2006-11-02

      You can look into XmlOutputterHook (Hook to customize Xml output).  I've used it to add custom info into the xml output.  This class has methods to add info in the beginning or end of report, for each failed / successful test, or in statistics.