1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00

UnitTestRunner: Improve tests status reporting

This commit is contained in:
Tom Poole 2022-07-08 11:48:50 +01:00
parent c52a049698
commit 0adbfee99d
2 changed files with 28 additions and 5 deletions

View file

@ -92,11 +92,29 @@ int main (int argc, char **argv)
else
runner.runAllTests (seed);
Logger::setCurrentLogger (nullptr);
std::vector<String> 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;
}

View file

@ -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));
}
}
}