Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duration not calculated for TEST_ORDERED() tests #228

Open
dfreiberger opened this issue Dec 7, 2023 · 4 comments
Open

Duration not calculated for TEST_ORDERED() tests #228

dfreiberger opened this issue Dec 7, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@dfreiberger
Copy link
Contributor

dfreiberger commented Dec 7, 2023

Describe the bug
Tests defined used TEST_ORDERED() do not appear to calculate the duration correctly.
image

A quick look into the code reveals that the Test StartedAt may not be set, as shown in this screenshot for SetFinishedAndDuration().
image

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

@dfreiberger
Copy link
Contributor Author

Easy fix in 8fdf256

I will look at adding unit tests tomorrow before creating PR.

@sagatowski sagatowski added the bug Something isn't working label Dec 7, 2023
@sagatowski
Copy link
Member

@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?

@dfreiberger
Copy link
Contributor Author

dfreiberger commented Dec 8, 2023

@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.
image
image

@dfreiberger
Copy link
Contributor Author

Fixed in PR #231

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants