bneumann / CppUTest-Test-Adapter

A test adapter for Visual Studio Code for the C/C++ Unit Test framework CppUTest.
MIT License
16 stars 7 forks source link

Display location of failure when a test fails #35

Closed jgonzalezdr closed 2 years ago

jgonzalezdr commented 2 years ago

...and last but not least, this PR fixes #23.

I've also removed whitespace trimming on subsequent lines because CppUTest for some string check failures reports the position of the mismatching character using a '^' character aligned using spaces to the left. Now the displayed error is exactly as if viewed on a terminal.

jgonzalezdr commented 2 years ago

Finally I've improved results output parsing a bit in order to properly display failure output like this one:

TEST(UtestShell, TestStopsAfterUnknownExceptionIsThrown)
C:\Work\cpputest\tests\CppUTest\UtestTest.cpp:214: error: Failure in TEST(UtestShell, TestStopsAfterUnknownExceptionIsThrown)
C:\Work\cpputest\src\CppUTest\TestTestingFixture.cpp:160: error:
        actual <
ExecFunction:1: error: Failure in TEST(ExecFunction, ExecFunction)
C:\Work\cpputest\tests\CppUTest\UtestTest.cpp:210: error:
        fail

.
Errors (1 failures, 1 tests, 1 ran, 1 checks, 0 ignored, 0 filtered out, 0 ms)

>
        did not contain  <Unexpected exception of unknown type was thrown>

 - 54 ms

Errors (1 failures, 865 tests, 1 ran, 2 checks, 0 ignored, 864 filtered out, 54 ms)

Now the parser captures all the info after the TEST(xxx, yyy) line up to the line indicating the elapsed time.

Additionally I've also fixed runs with errors (not failures, e.g., due to a unhandled exception in tested code) to be properly detected and the output information being captured, like this one:

TEST(Config, GenericTypeOverrideOptions_AllowedTypes)terminate called after throwing an instance of 'std::runtime_error'
  what():  Invalid parameter override option type ['#type16=POD'].