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 disappears from GTA after exception #295

Closed
vko-insiders opened this issue Sep 16, 2019 · 11 comments
Closed

Test disappears from GTA after exception #295

vko-insiders opened this issue Sep 16, 2019 · 11 comments
Assignees
Milestone

Comments

@vko-insiders
Copy link

Hey, I'm using VS2017 v15.9.16 with GTA 0.16.1.1369 (installed via Tools -> Extensions and Updates).

When there is an unhandled exception during a test execution, the test is disappearing from the GTA-list.
In comparison: When reproducing the same behavior with MS-Test, the test remains with a red error message: Message: Failed to set up the execution context to run the test.

So I think this is a improvement-request to keep tests that failed hard in the GTA-list.

@csoltenborn
Copy link
Owner

This is surprising, I haven't seen such behavior before. Can you provide a minimal sample solution which demonstrates the issue?

@vko-insiders
Copy link
Author

Unfortunately I cannot reproduce my issue at the moment.
I will close this ticket and reopen a new ticket if I can reproduce it with a minimal example.

@c-stubbe
Copy link

I work in the same company as vko-insiders and frequently face the same problem.
I've built a sample solution which demonstrates the issue, see Tests.zip. The solutions consists out of three projects: Dll, GoogleTest and MsTest.

Steps to reproduce:

  1. Open the solution and click "Run All" in the Test Explorer.
  2. All three projects will be built, both tests will be executed and should be green.
  3. Delete the file "Dll.dll" in the "Debug" subfolder and rerun both tests (do not click "Run All" as it will rebuild the DLL.dll).
  4. MsTest will get red with the message "Failed to set up the execution context to run the test". GoogleTest will disappear from the Test Explorer.

You can now build the Dll project or even the whole solution or click "Run All". GoogleTest will not appear in the Test Explorer.
The only way to make it appear again is to rebuild the GoogleTest project or to close and reopen the solution. Both take considerable time in our real solution.

@vko-insiders vko-insiders reopened this Sep 19, 2019
@csoltenborn
Copy link
Owner

Ok, I have watched the behavior, but this is a rather weird scenario, isn't it? Why would you delete that DLL from outside VS?

Anyways. here's what's happening: GTA gets the order from VS to execute the test. However, execution fails due to the missing DLL. GTA recognizes this and prints an according warning: [GTA 20:54:55.666 Warning] 1 test cases seem to not have been run - are you repeating a test run, but tests have changed in the meantime? Test cases: TestCaseName.TestName. And since GTA does not report a test result, VS apparently removes the test from test explorer.

IMHO, this is reasonable behavior, because the test is not available - test discovery would also result in the test not existing (try running GoogleTest.exe on the console after removing that DLL).

Btw, I would argue that your solution has a minor issue: The GoogleTest project lacks a reference to the Dll project. In fact, if that reference exists, the described behavior appears to not be possible - might it be a good idea to add that reference?

@c-stubbe
Copy link

This was just a sample solution to reproduce the problem. We faced the problem with external DLLs (mainly from Qt) which were not built in the same solution.
E. g. a test suite is green, I add another test which uses a new Qt module (and thus a new DLL), I rerun the test suite and the test suite disappears. I notice my mistake and add the missing DLL, but cannot rerun the test suite as it is missing.
IMHO, the test should be red, so I can fix it (be adding a DLL) and run it again.
The test executables are not in the same folder than the main executables, which makes the question which DLLs are needed in which folder even more complicated -- I can't be sure that the test will find all necessary DLLs even when the main executable finds all DLLs.

If I understood correctly, it would be possible for GTA to report "test not found" as test result which would solve the problem.
Can this be implemented?

@csoltenborn
Copy link
Owner

Yes, it can! Feel free to give this build a try...

@c-stubbe
Copy link

Thanks!
With "ReportAsFailed" it behaves like I thought it should. I can add the missing DLLs and rerun the one test I am interested in, without having to rebuild anything.
The only thing I noticed is the test result message ("Test case has not been run due to unkown reasons"). This could be made more clearly (maybe "The test case could not be run. There may be a dependency missing since test discovery.").

Will this feature be included in the next release?

Again, thanks for implementing it so quickly.

@csoltenborn
Copy link
Owner

Yes, it will go intothe next release, and this won't take too long (maybe next weekend). I haven't yet decided which setting will be the default one, though - I might go for Do not report to not change existing behavior...

The test message is not as obvious as it appears to you: For instance, perform discovery, comment out a certain test, and run that same test via right-clicking and selecting Run selected tests. Same behavior, although the test executable runs just fine. That's the use case for printing the warning in debug mode as GTA already does...

@c-stubbe
Copy link

c-stubbe commented Oct 1, 2019

Good. I'm looking forward to the next release.

Both is OK with me.
The default setting is not that important. It won't be the only setting which we change after new Visual Studio installs -- and could even be included in that gta.runsettings file.
I agree that there are other reasons why the test can't be run, so "unknown reasons" may be the best message.

@csoltenborn csoltenborn self-assigned this Oct 6, 2019
@csoltenborn csoltenborn added this to the 0.17.0 milestone Oct 6, 2019
csoltenborn added a commit that referenced this issue Oct 6, 2019
…ng_tests_configurable

#295 make behavior for missing tests configurable
@csoltenborn
Copy link
Owner

Enhancement has been released - enjoy!

Closing...

@c-stubbe
Copy link

c-stubbe commented Oct 8, 2019

Thanks.
The new release, installed from the VS marketplace, works as it should.
I like the detailed test message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants