diff --git a/extras/UnitTestRunner/Source/Main.cpp b/extras/UnitTestRunner/Source/Main.cpp index b78d5c1f76..db4abf2597 100644 --- a/extras/UnitTestRunner/Source/Main.cpp +++ b/extras/UnitTestRunner/Source/Main.cpp @@ -92,11 +92,29 @@ int main (int argc, char **argv) else runner.runAllTests (seed); - Logger::setCurrentLogger (nullptr); + std::vector failures; for (int i = 0; i < runner.getNumResults(); ++i) - if (runner.getResult(i)->failures > 0) - return 1; + { + auto* result = runner.getResult (i); + + if (result->failures > 0) + failures.push_back (result->unitTestName + " / " + result->subcategoryName + ": " + String (result->failures) + " test failure" + (result->failures > 1 ? "s" : "")); + } + + if (! failures.empty()) + { + logger.writeToLog (newLine + "Test failure summary:" + newLine); + + for (const auto& failure : failures) + logger.writeToLog (failure); + + Logger::setCurrentLogger (nullptr); + return 1; + } + + logger.writeToLog (newLine + "All tests completed successfully"); + Logger::setCurrentLogger (nullptr); return 0; } diff --git a/modules/juce_core/unit_tests/juce_UnitTest.cpp b/modules/juce_core/unit_tests/juce_UnitTest.cpp index 1b218eed82..564d55eaed 100644 --- a/modules/juce_core/unit_tests/juce_UnitTest.cpp +++ b/modules/juce_core/unit_tests/juce_UnitTest.cpp @@ -194,6 +194,11 @@ bool UnitTestRunner::shouldAbortTests() return false; } +static String getTestNameString (const String& testName, const String& subCategory) +{ + return testName + " / " + subCategory; +} + void UnitTestRunner::beginNewTest (UnitTest* const test, const String& subCategory) { endTest(); @@ -203,7 +208,7 @@ void UnitTestRunner::beginNewTest (UnitTest* const test, const String& subCatego results.add (new TestResult (testName, subCategory)); logMessage ("-----------------------------------------------------------------"); - logMessage ("Starting test: " + testName + " / " + subCategory + "..."); + logMessage ("Starting tests in: " + getTestNameString (testName, subCategory) + "..."); resultsUpdated(); } @@ -226,7 +231,7 @@ void UnitTestRunner::endTest() } else { - logMessage ("All tests completed successfully"); + logMessage ("Completed tests in " + getTestNameString (r->unitTestName, r->subcategoryName)); } } }