reporter.testSetCompleted( testSetReportEntry, stats );
reporter.testSetCompleted( testSetReportEntry, rerunStats );
FileInputStream fileInputStream = new FileInputStream( expectedReportFile );
Xpp3Dom testSuite = Xpp3DomBuilder.build( new InputStreamReader( fileInputStream, "UTF-8" ) );
assertEquals( "testsuite", testSuite.getName() );
// 0.019 = 0.012 + 0.005 +0.002
assertEquals( "0.019", testSuite.getAttribute( "time" ) );
Xpp3Dom properties = testSuite.getChild( "properties" );
assertEquals( System.getProperties().size(), properties.getChildCount() );
Xpp3Dom child = properties.getChild( 1 );
assertFalse( StringUtils.isEmpty( child.getAttribute( "value" ) ) );
assertFalse( StringUtils.isEmpty( child.getAttribute( "name" ) ) );
Xpp3Dom[] testcase = testSuite.getChildren( "testcase" );
Xpp3Dom testCaseOne = testcase[0];
assertEquals( TEST_ONE, testCaseOne.getAttribute( "name" ) );
assertEquals( "0.012", testCaseOne.getAttribute( "time" ) );
assertEquals( this.getClass().getName(), testCaseOne.getAttribute( "classname" ) );
Xpp3Dom testCaseTwo = testcase[1];
assertEquals( TEST_TWO, testCaseTwo.getAttribute( "name" ) );
// Run time for a rerun failing test is the run time of the first run
assertEquals( "0.005", testCaseTwo.getAttribute( "time" ) );
assertEquals( Inner.class.getName(), testCaseTwo.getAttribute( "classname" ) );
Xpp3Dom errorNode = testCaseTwo.getChild( "error" );
Xpp3Dom rerunErrorNode = testCaseTwo.getChild( "rerunError" );
assertNotNull( errorNode );
assertNotNull( rerunErrorNode );
assertEquals( "A fud msg", errorNode.getAttribute( "message" ) );
assertEquals( "fail at foo", errorNode.getAttribute( "type" ) );
// Check rerun error node contains all the information
assertEquals( firstRunOut, testCaseTwo.getChild( "system-out" ).getValue() );
assertEquals( firstRunErr, testCaseTwo.getChild( "system-err" ).getValue() );
assertEquals( secondRunOut, rerunErrorNode.getChild( "system-out" ).getValue() );
assertEquals( secondRunErr, rerunErrorNode.getChild( "system-err" ).getValue() );
assertEquals( "A fud msg two", rerunErrorNode.getAttribute( "message" ) );
assertEquals( "fail at foo two", rerunErrorNode.getAttribute( "type" ) );
// Check flaky failure node
Xpp3Dom testCaseThree = testcase[2];
assertEquals( TEST_THREE, testCaseThree.getAttribute( "name" ) );
// Run time for a flaky test is the run time of the first successful run
assertEquals( "0.002", testCaseThree.getAttribute( "time" ) );
assertEquals( Inner.class.getName(), testCaseThree.getAttribute( "classname" ) );
Xpp3Dom flakyFailureNode = testCaseThree.getChild( "flakyFailure" );
assertNotNull( flakyFailureNode );
assertEquals( firstRunOut, flakyFailureNode.getChild( "system-out" ).getValue() );
assertEquals( firstRunErr, flakyFailureNode.getChild( "system-err" ).getValue() );
// system-out and system-err should not be present for flaky failures
assertNull( testCaseThree.getChild( "system-out" ) );
assertNull( testCaseThree.getChild( "system-err" ) );
}