tcunit / TcUnit-Runner

Program that makes it possible to automate runs of TcUnit unit tests
Other
34 stars 17 forks source link

Double items in ErrorList causes TcUnitResultCollector to fail #37

Closed Bulkje closed 6 months ago

Bulkje commented 2 years ago

Describe the bug A clear and concise description of what the bug is. Double lines in ErrorList causes TcUnitResultCollector to fail

To Reproduce What steps are necessary to reproduce the behavior? When you have enough tests that you need to loop though the while (true) loop in program.cs multiple times, the line var newErrors = errorList.AddNew(errorItems); gets called twice or more. this has the effect of errorList getting double messages. I discovered this by printing the ErrorList to a file, and seeing double lines. The output was fine in VS TwinCAT output console.

Expected behavior A clear and concise description of what you expected to happen. Errorlist shouldn't have double messages.

Screenshots If applicable, add screenshots to help explain your problem.

Software versions Which version of the applicable software did you use? (TcUnit-Runner, TcUnit library, TwinCAT XAE version, Visual Studio version etc) TcUnit-Runner built from GitHub, TcUnit library latest release, VS 2017, TwinCAT v3.1.2024.12

Run environment Under what environment did you run the software? PLC? Virtual machine? Windows, localhost 'PLC'

Additional context Have you tried running the software without TcUnit-Runner and making sure you get the results? Add any other context about the problem here. When I run the same test suite on the same machine without TcUnit-Runner, I get the correct output in the console.

sagatowski commented 2 years ago

Is this somehow related to https://github.com/tcunit/TcUnit/issues/92? When you say double lines, do you mean that you get one output extra in the visual studio event list for every entry? When do you get double lines? Do you have an example project when double lines are received?

Bulkje commented 2 years ago

No I don't think the problem is related to tcunit/TcUnit#92, because the errorlist was fine in the output window. The problem arose when TcUnit-Runner scraped the error list. In the output window from the runner I could see it waiting for results.

2022-03-16 12:36:28 [INFO ] - Waiting for results from TcUnit...
2022-03-16 12:36:38 [INFO ] - ... got 225 report lines so far.
2022-03-16 12:36:48 [INFO ] - ... got 324 report lines so far.
2022-03-16 12:36:48 [INFO ] - All results from TcUnit obtained

Note that the code looped inside the while loop twice before returning the error list. Because of linked lists, I think the debug variable in the while(true) loop in program.cs would add the results to the regular errorlist as well. When I added code to read the errorlist directly, I got this output:

16/03/2022 13:36:33 000 ms | 'TwinCAT System' (10000): Starting COM Server TcEventLogger !
16/03/2022 13:36:33 351 ms | 'PlcTask' (350): | Test suite ID=0 'MAIN.Administration_Test'
16/03/2022 13:36:33 370 ms | 'PlcTask' (350): | ID=0 number of tests=72, number of failed tests=0
16/03/2022 13:36:33 390 ms | 'PlcTask' (350): | Test name=Administration_Test_deleteTest
16/03/2022 13:36:33 410 ms | 'PlcTask' (350): | Test class name=MAIN.Administration_Test
16/03/2022 13:36:33 430 ms | 'PlcTask' (350): | Test status=PASS, number of asserts=4
16/03/2022 13:36:33 450 ms | 'PlcTask' (350): | Test name=Administration_Test_removeChildTest
16/03/2022 13:36:33 450 ms | 'PlcTask' (350): | Test name=Administration_Test_removeChildTest

This is just the first repeated line, there are many others. And then the error from the runner made sense:

2022-03-16 12:36:58 [INFO ] - 16/03/2022 13:36:33 450 ms | 'PlcTask' (350): | Test name=Administration_Test_removeChildTest
2022-03-16 12:36:58 [ERROR] - While parsing TcUnit results, expected TEST_CLASS_NAME but got TEST_NAME

So I fixed it by moving the debug variable inside the if statement that checks if the program is in debug mode. And the error messages in TcUnitResultCollector.cs were the wrong way around. (see pull request #38 for these fixes)

sagatowski commented 6 months ago

This project is archived. Replacement for it is in the works.