#34 Detailed test report

open
nobody
5
2004-03-25
2004-03-25
No

I have asked for a detailed test report in the open
discussion.

I was guided how to solve it and solved it.
In this feature request I shall describe the original whish
and then I shall give my solution (See attached zip.)

My request would be that based on my solution add the
code to the CppUnit or add somthing simmilar.
The code definitly needs refactoring because currently
is writed to be external part and not part of CppUnit.

***************************************
********* Original Whish ******************
***************************************

What I am seeking is make a detailed test report.
If I do this for example:

// Create the event manager and test controller
CPPUNIT_NS::TestResult controller;

// Add a listener that collects test result
CPPUNIT_NS::TestResultCollector result;
controller.addListener( &result );

CppUnit::TestRunner runner;
runner.addTest(
CPPUNIT_NS::TestFactoryRegistry::getRegistry
().makeTest() );
runner.run( controller , "" );

std::ofstream file( "results.xml" );
CPPUNIT_NS::XmlOutputter xml( &result, file );
xml.write();
file.close();

Then this code will generate to me (for example) a a
folowing test report:

<?xml version="1.0" encoding='ISO-8859-1'
standalone='yes' ?>
<TestRun>
<FailedTests>
<FailedTest id="2">
<Name>CFirstTester::secondFunction</Name>
<FailureType>Assertion</FailureType>
<Location>
<File>D:\CppUnitTesting\FirstAcceptable\FirstTester.cpp
</File>
<Line>40</Line>
</Location>
<Message>assertion failed
- Expression: false
</Message>
</FailedTest>
</FailedTests>
<SuccessfulTests>
<Test id="1">
<Name>CFirstTester::firstTest</Name>
</Test>
<Test id="3">
<Name>CFirstTester::thirdFunction</Name>
</Test>
</SuccessfulTests>
<Statistics>
<Tests>3</Tests>
<FailuresTotal>1</FailuresTotal>
<Errors>0</Errors>
<Failures>1</Failures>
</Statistics>
</TestRun>

Now what I want is that the report might look like this:

<FailedTests>
<FailedTest id="2">
<Name>CFirstTester::secondFunction</Name>
<Identification>Requirement Key That is
Tested</Identification>
<InputAction>The Input Action</InputAction>
<ExpectedOutcome>Expected
Outcome</ExpectedOutcome>
<RealOutcome>The Real Outcome</RealOutcome>
<Result>Fail</Result>
<FailureType>Assertion</FailureType>
<Location>
<File>D:\CppUnitTesting\FirstAcceptable\FirstTester.cpp
</File>
<Line>40</Line>
</Location>
<Message>assertion failed
- Expression: false
</Message>
</FailedTest>

And in case of succes to:

<Test id="1">
<Name>CFirstTester::firstTest</Name>
<Identification>Requirement Key That is
Tested</Identification>
<InputAction>The Input Action</InputAction>
<ExpectedOutcome>Expected
Outcome</ExpectedOutcome>
<RealOutcome>The Real Outcome</RealOutcome>
<Result>Pass</Result>
</Test>

Also a Preconditons and Postcondition fields would be
also usefull before the test.

Now I would like to do this the most easy way for
example in the test function:

void CFirstTester::firstTest()
{
CPPUNIT_Identification("Requirement Key That is
Tested");
CPPUNIT_InputAction("The Input Action");
CPPUNIT_ExpectedOutcome("Expected Outcome");

... Code ...

if ( test )
{
CPPUNIT_RealOutcome("The Real Outcome")
CPPUNIT_Result("Pass");
}
else
{
CPPUNIT_RealOutcome("The Real Outcome")
CPPUNIT_Result("Fail");
CPPUNIT_ASSERT( test );
}

An easier version commenting would be also good for
example instead of
CPPUNIT_RealOutcome("The Real Outcome");
would be
CPPUNIT_COMMENT("RealOutcome","The Real Outcome");

Discussion

  • Ekart Laszlo

    Ekart Laszlo - 2004-03-25

    The Extension to CppUnit to give detailed Infos

     
  • Nobody/Anonymous

    Logged In: NO

    hi

    can u send me the details how did u solve the problem

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks