Skip to content

Commit

Permalink
If want successful test output, include messages (CleverRaven#51441)
Browse files Browse the repository at this point in the history
The output for successful tests, even if such is requested of via
Catch2's `-s` flag, now includes messages; it didn't before.

Co-authored-by: actual-nh <[email protected]>
  • Loading branch information
actual-nh and actual-nh authored Sep 6, 2021
1 parent eede07d commit cc98274
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,16 @@ struct CataListener : Catch::TestEventListenerBase {

void sectionEnded( Catch::SectionStats const &sectionStats ) override {
TestEventListenerBase::sectionEnded( sectionStats );
if( !sectionStats.assertions.allPassed() ) {
if( !sectionStats.assertions.allPassed() ||
m_config->includeSuccessfulResults() ) {
std::vector<std::pair<std::string, std::string>> messages =
Messages::recent_messages( 0 );
if( !messages.empty() ) {
stream << "Log messages during failed test:\n";
if( !sectionStats.assertions.allPassed() ) {
stream << "Log messages during failed test:\n";
} else {
stream << "Log messages during successful test:\n";
}
}
for( const std::pair<std::string, std::string> &message : messages ) {
stream << message.first << ": " << message.second << '\n';
Expand Down

0 comments on commit cc98274

Please sign in to comment.