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

Added startTime and endTime to UnitTest TestResult struct

This commit is contained in:
ed 2020-06-17 14:52:57 +01:00
parent e7004e634c
commit 802d73f73f
2 changed files with 20 additions and 9 deletions

View file

@ -199,15 +199,11 @@ void UnitTestRunner::beginNewTest (UnitTest* const test, const String& subCatego
endTest();
currentTest = test;
auto* r = new TestResult();
results.add (r);
r->unitTestName = test->getName();
r->subcategoryName = subCategory;
r->passes = 0;
r->failures = 0;
auto testName = test->getName();
results.add (new TestResult (testName, subCategory));
logMessage ("-----------------------------------------------------------------");
logMessage ("Starting test: " + r->unitTestName + " / " + subCategory + "...");
logMessage ("Starting test: " + testName + " / " + subCategory + "...");
resultsUpdated();
}
@ -216,6 +212,8 @@ void UnitTestRunner::endTest()
{
if (auto* r = results.getLast())
{
r->endTime = Time::getCurrentTime();
if (r->failures > 0)
{
String m ("FAILED!! ");

View file

@ -376,18 +376,31 @@ public:
*/
struct TestResult
{
TestResult() = default;
explicit TestResult (const String& name, const String& subCategory)
: unitTestName (name),
subcategoryName (subCategory)
{
}
/** The main name of this test (i.e. the name of the UnitTest object being run). */
String unitTestName;
/** The name of the current subcategory (i.e. the name that was set when UnitTest::beginTest() was called). */
String subcategoryName;
/** The number of UnitTest::expect() calls that succeeded. */
int passes;
int passes = 0;
/** The number of UnitTest::expect() calls that failed. */
int failures;
int failures = 0;
/** A list of messages describing the failed tests. */
StringArray messages;
/** The time at which this test was started. */
Time startTime = Time::getCurrentTime();
/** The time at which this test ended. */
Time endTime;
};
/** Returns the number of TestResult objects that have been performed.