mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
INFO()s are only cleared by failures or end of test case
This commit is contained in:
parent
89c464709e
commit
034c8b6248
@ -21,20 +21,28 @@ TEST_CASE( "succeeding/message", "INFO and WARN do not abort tests" )
|
|||||||
TEST_CASE( "failing/message/info/1", "INFO gets logged on failure" )
|
TEST_CASE( "failing/message/info/1", "INFO gets logged on failure" )
|
||||||
{
|
{
|
||||||
INFO( "this message should be logged" );
|
INFO( "this message should be logged" );
|
||||||
|
INFO( "so should this" );
|
||||||
int a = 2;
|
int a = 2;
|
||||||
REQUIRE( a == 1 );
|
REQUIRE( a == 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE( "failing/message/info/2", "INFO gets logged on failure" )
|
TEST_CASE( "failing/message/info/2", "INFO gets logged on failure" )
|
||||||
{
|
{
|
||||||
INFO( "this message should not be logged" );
|
|
||||||
int a = 2;
|
|
||||||
REQUIRE( a == 2 );
|
|
||||||
|
|
||||||
INFO( "this message should be logged" );
|
INFO( "this message should be logged" );
|
||||||
INFO( "so should this" );
|
int a = 2;
|
||||||
|
CHECK( a == 2 );
|
||||||
|
|
||||||
REQUIRE( a == 1 );
|
INFO( "this message should be logged, too" );
|
||||||
|
|
||||||
|
CHECK( a == 1 );
|
||||||
|
|
||||||
|
INFO( "and this, but later" );
|
||||||
|
|
||||||
|
CHECK( a == 0 );
|
||||||
|
|
||||||
|
INFO( "but not this" );
|
||||||
|
|
||||||
|
CHECK( a == 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE( "failing/message/fail", "FAIL aborts the test" )
|
TEST_CASE( "failing/message/fail", "FAIL aborts the test" )
|
||||||
|
@ -141,7 +141,7 @@ namespace Catch
|
|||||||
ResultsCapture::acceptMessage( "unknown exception" );
|
ResultsCapture::acceptMessage( "unknown exception" );
|
||||||
ResultsCapture::acceptResult( ResultWas::ThrewException );
|
ResultsCapture::acceptResult( ResultWas::ThrewException );
|
||||||
}
|
}
|
||||||
|
m_info.clear();
|
||||||
m_reporter->EndTestCase( testInfo, redirectedCout, redirectedCerr );
|
m_reporter->EndTestCase( testInfo, redirectedCout, redirectedCerr );
|
||||||
ResultsCapture::setListener( prevListener );
|
ResultsCapture::setListener( prevListener );
|
||||||
}
|
}
|
||||||
@ -160,26 +160,24 @@ namespace Catch
|
|||||||
virtual void testEnded( const ResultInfo& result )
|
virtual void testEnded( const ResultInfo& result )
|
||||||
{
|
{
|
||||||
if( result.getResultType() == ResultWas::Ok )
|
if( result.getResultType() == ResultWas::Ok )
|
||||||
|
{
|
||||||
m_successes++;
|
m_successes++;
|
||||||
|
}
|
||||||
else if( !result.ok() )
|
else if( !result.ok() )
|
||||||
|
{
|
||||||
m_failures++;
|
m_failures++;
|
||||||
|
|
||||||
if( !result.ok() )
|
|
||||||
{
|
|
||||||
std::vector<ResultInfo>::const_iterator it = m_info.begin();
|
std::vector<ResultInfo>::const_iterator it = m_info.begin();
|
||||||
std::vector<ResultInfo>::const_iterator itEnd = m_info.end();
|
std::vector<ResultInfo>::const_iterator itEnd = m_info.end();
|
||||||
for(; it != itEnd; ++it )
|
for(; it != itEnd; ++it )
|
||||||
m_reporter->Result( *it );
|
m_reporter->Result( *it );
|
||||||
}
|
|
||||||
if( result.getResultType() == ResultWas::Info )
|
|
||||||
{
|
|
||||||
m_info.push_back( result );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_info.clear();
|
m_info.clear();
|
||||||
m_reporter->Result( result );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( result.getResultType() == ResultWas::Info )
|
||||||
|
m_info.push_back( result );
|
||||||
|
else
|
||||||
|
m_reporter->Result( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool sectionStarted( const std::string& name, const std::string& description, std::size_t& successes, std::size_t& failures )
|
virtual bool sectionStarted( const std::string& name, const std::string& description, std::size_t& successes, std::size_t& failures )
|
||||||
|
Loading…
Reference in New Issue
Block a user