Duration not calculated for TEST_ORDERED() tests
Describe the bug
Tests defined used TEST_ORDERED() do not appear to calculate the duration correctly.
A quick look into the code reveals that the Test StartedAt may not be set, as shown in this screenshot for SetFinishedAndDuration().
It looks like a simple fix to the TEST_ORDERED FC to add Test.SetStartedAtIfNotSet(Timestamp := F_GetCpuCounterAs64bit(GVL_TcUnit.GetCpuCounter)); is necessary. I will try to submit a PR as soon as I have time for this.
To Reproduce
Run any set of tests that include TEST_ORDERED tests. For example TestCase1C will be calculated incorrectly while TestCase1D is correct.
IF TEST_ORDERED('TestCase1C') THEN
AssertTrue(TRUE, 'Condition is not true');
TEST_FINISHED();
END_IF
TEST('TestCase1D');
AssertTrue(FALSE, 'Condition is not true');
AssertTrue(TRUE, 'Condition is not true');
TEST_FINISHED();
Expected behavior The duration should be calculated for the overall length of time that the test takes.
Software versions 1.3.0.0
Run environment Hardware PLC
Easy fix in https://github.com/tcunit/TcUnit/commit/8fdf2564b54d48e4d64c646f0682e12227cb9d52
I will look at adding unit tests tomorrow before creating PR.
@dfreiberger Thanks for this discovery. Looking forward to your PR. ❤
Are you using TcUnit-VsExtension for your nice integration of TcUnit into TwinCAT?
Also, something feels different about the colors and font of your IDE? What nice font is that?
@sagatowski yes, I am using TcUnit-VsExtension + the adapter using the branch I am working on at TcUnit-VsTestAdapter that can parse out tests via the TMC file and regex parsing for TEST and TEST_ORDERED sections. The fonts and colors I think are just defaults in TwinCAT VS 2019 although maybe I adjusted something at one point. The font is Consolas.
Fixed in PR #231
Fixed in https://github.com/tcunit/TcUnit/pull/231.