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

Test output parser confuses exception message with error location #157

Closed
gobater opened this issue Aug 9, 2017 · 5 comments
Closed

Test output parser confuses exception message with error location #157

gobater opened this issue Aug 9, 2017 · 5 comments
Assignees
Labels
Milestone

Comments

@gobater
Copy link

gobater commented Aug 9, 2017

Hi,

I have a strange behavior with GoogleTestAdapter in tests that throw exceptions

The output of the window looks like the following file: test_output.txt

The test result window shows the following for "Test.WithStackTrace" (filename string is cut)
image

However, for "Test.WithoutStackTrace" shows the following (correct exception text, but no StackTrace)
image

As you can see, the GoogleTestAdapter, does not parse correctly the test output. Notice the dash ("-") after the ":" at the end of the filename in the exception text of "Test.WithoutStackTrace"

I would expect to see the correct text (result message) and the Stack Trace in both tests

You can reproduce the failures with the following code
example_code.cpp.txt

@csoltenborn
Copy link
Owner

Now that's what I call a bug report! 👍

However, the adapter's behavior is not as strange as it looks - here's the output your sample code produces:

[----------] 2 tests from Test
[ RUN      ] Test.WithStackTrace
unknown file: error: C++ exception with description "Assertion failed in c:\users\chris\git\googletestadapter\sampletests\tests\basictests.cpp:174" thrown in the test body.
[  FAILED  ] Test.WithStackTrace (1 ms)
[ RUN      ] Test.WithoutStackTrace
unknown file: error: C++ exception with description "Assertion failed in c:\users\chris\git\googletestadapter\sampletests\tests\basictests.cpp:-179" thrown in the test body.
[  FAILED  ] Test.WithoutStackTrace (0 ms)
[----------] 2 tests from Test (3 ms total)

The unkown file part is the place where gtest prints out the location of the assertion failure - that's what we use to produce the stack trace element. Now, your TestWithStackTrace has an error message containing the exact same format we are looking for when trying to figure out the stack trace element (i.e., file:line), and that apparently confuses our parser: it produces a stack trace element from the exception message, and that part is then not used any more for the test's error message. This is the bug part, so to speak.

Your TestWithoutStackTrace does not have this problem due to the inserted - and therefore behaves correctly. I fear that Google is to blame here for not providing error location (and thus, we cannot provide a stack trace element).

Of course, we can not rely on the exception message containing the exception's location. We will still try to fix the first problem!

@csoltenborn csoltenborn changed the title StackTrace missing in test result window... Test output parser confuses exception message with error location Aug 10, 2017
@gobater
Copy link
Author

gobater commented Aug 10, 2017

Hi Chris,

Basically, you are telling us that GoogleTestAdapter produces a StackTrace in the first case just "by luck". Only because our Exception text contains the file name ":" line (since Google does not procude in this case the correct Output? Wow! Impressive how Lucky we are here!

Thanks for your support

@csoltenborn
Copy link
Owner

You're welcome. Sometimes, all you need is luck :-)

@gobater
Copy link
Author

gobater commented Aug 10, 2017

and... I am still going to have "luck" after your fix? :-) --> in case that google is not able to provide the information concerning the file producing the exception but message contains valid information, are you going to keep the old behavior?

@csoltenborn
Copy link
Owner

csoltenborn commented Aug 10, 2017

No, I don't think so... That's what I meant with "we can not rely on the exception message containing the exception's location". I think you are being stuck with the location of the test case itself.

However, have a look at our (i.e., gtest's) option Catch exceptions, which might be what you need! Btw, this option is also available via toolbar.

@csoltenborn csoltenborn added this to the 0.11.0 milestone Sep 24, 2017
@csoltenborn csoltenborn self-assigned this Sep 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants