Browse Source

Added startTime and endTime to UnitTest TestResult struct

tags/2021-05-28
ed 5 years ago
parent
commit
802d73f73f
2 changed files with 20 additions and 9 deletions
  1. +5
    -7
      modules/juce_core/unit_tests/juce_UnitTest.cpp
  2. +15
    -2
      modules/juce_core/unit_tests/juce_UnitTest.h

+ 5
- 7
modules/juce_core/unit_tests/juce_UnitTest.cpp 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!! ");


+ 15
- 2
modules/juce_core/unit_tests/juce_UnitTest.h 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.


Loading…
Cancel
Save