mirror of
https://github.com/unittest-cpp/unittest-cpp
synced 2026-09-26 16:19:30 +03:00
Reduce possible timing test failures
TestFinishIsCalledWithCorrectTime was reliant on SleepMs(20) waking up before a certain threshold was hit, which is not reliable. This change uses the actual time of running tests as the top threshold; not a great improvement but a good quick fix. Fixes #90
This commit is contained in:
parent
2fc284af64
commit
44aa33b02b
1 changed files with 8 additions and 1 deletions
|
|
@ -110,8 +110,15 @@ namespace
|
|||
SlowTest test;
|
||||
list.Add(&test);
|
||||
|
||||
// Using UnitTest::Timer here is arguably a bit hokey and self-recursive, but
|
||||
// it should guarantee that the test time recorded is less than that plus the
|
||||
// overhead of RunTestsIf -- the only thing we can reliably assert without
|
||||
// reworking the test to not use sleeps at all
|
||||
Timer actual;
|
||||
actual.Start();
|
||||
RunTestsIf(list, NULL, True(), 0);
|
||||
CHECK(reporter.lastFinishedTestTime >= 0.005f && reporter.lastFinishedTestTime <= 0.050f);
|
||||
|
||||
CHECK(reporter.lastFinishedTestTime >= 0.005f && reporter.lastFinishedTestTime <= actual.GetTimeInMs());
|
||||
}
|
||||
|
||||
TEST_FIXTURE(TestRunnerFixture, FailureCountIsZeroWhenNoTestsAreRun)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue