csoltenborn / GoogleTestAdapter

Visual studio extension that adds support for the C++ testing framework Google Test.
Other
143 stars 100 forks source link

Failed to run test executable #322

Closed tongyuze closed 3 years ago

tongyuze commented 3 years ago

Hi there,

Recently I found an weird issue in our tests. We have 6 test files to be executed each run, but now only one file could be executed. The others will fail. The error we saw is:

[error]Failed to run test executable 'path\tests.exe': No process is associated with this object.

Found 0 tests in executable...

Have you ever seen issues like that?

Thanks!

csoltenborn commented 3 years ago

No, I have not... Does this happen all the time?

If you increase GTA's output mode to Debug, you will get slightly more information, but I'm not sure whether this will help...

tongyuze commented 3 years ago

Thanks for your reply. This happens all the time. The weird thing is we have these tests for a long time, and it was good. From the end of the January, the error came out suddenly. Do you know how to change it in debug mode via azure pipeline task?

csoltenborn commented 3 years ago

Sure I do ;-) You need to configure a RunSettings file - see here and here. But don't expect too much - this will merely print out the exception caught if I remember correctly (instead of only the exception message, which is "No process is associated with this object" in this case).

tongyuze commented 3 years ago

@csoltenborn Actually this issue happens because the discover test time became longer suddenly for some reason (I don't know why). I found two solutions here:

  1. Turn off "real time virus protection". With this operation, the discovery time will get back to normal. However, it might be dangerous to do this.
  2. Changed settings of discovery test timeout to 150 seconds from default. I tried multiple times and found this number is enough to complete the process. Do you have any idea about the root cause of this?

Thank you!

csoltenborn commented 3 years ago

That's indeed interesting and might actually be a little bug! First of all, test discovery time should be in your responsibility: All GTA does is run the executable and process the resulting output. My guess would be that discovery also takes longer if you run the executable via the console. In Debug mode, GTA should print the exact command it executes, so you can try that out yourself if you want to (and maybe do some debugging to figure out why the executable behaves like that).

However, to avoid test discovery being stuck in case the executable does not return for some reason, GTA uses the mentioned timeout. If it passes, GTA kills the according process, and that might fit the error message you reported. Thus, the bug would be that GTA should report that the discovery process had been stopped because of a timeout, and not try to proceed further. I will look into this, but it might take some time...

Just in case: You can configure that timeout via the RunSettings file as described above.

csoltenborn commented 3 years ago

Oops, I just found the solution: Apparently, you are not using Google Test Adapter, but Test Adapter for Google Test (the MS clone of this extension) - my extension behaves correctly and would have saved you the hassle. This is how GTA handles this issue.

Thus, I'm doing support for a MS product here :-) So please either start to use my adapter, or continue asking on this repository.

tongyuze commented 3 years ago

Oh, I didn't realize they are different... Thank you for your specific explanation.

By the way, do you think the antimalware service executable could cause a issue like this? Because it just behaves like before after turning it off.

csoltenborn commented 3 years ago

No idea...