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

Unit Tests Trigger 2nd Time In Background Automatically #225

Closed
eklnc opened this issue Feb 7, 2022 · 1 comment
Closed

Unit Tests Trigger 2nd Time In Background Automatically #225

eklnc opened this issue Feb 7, 2022 · 1 comment

Comments

@eklnc
Copy link

eklnc commented Feb 7, 2022

Installed product versions

  • Visual Studio: 2019 Community
  • This extension: 1.1.154

Description

Unit tests in a project always run background 2nd time by fcc. I don't understand why it is necessary to trigger 2nd time. It is also triggered when a unit test has been updated.

Steps to recreate

  1. You must have a unit test that uses a process object like this -> var process = new Process();
  2. And then this process must be started with notepad like this -> var process = new Process { StartInfo = new ProcessStartInfo { FileName = "notepad.exe" } };
  3. Ran the tests or update a random test
  4. Wait for a couple of minutes

Current behavior

notepad.exe triggered 2nd time after running a unit test or updating a unit test.

Expected behavior

I do not want a 2nd trigger

@tonyhallett
Copy link
Collaborator

tonyhallett commented Feb 7, 2022

FCC hooks into the test execution to obtain all the necessary information required to run code coverage. As such it is the code coverage that is the second test run.

There are three possible solutions to this.

  1. FCC provides its own UI.
  2. We cancel the first run based upon a flag and of course the test explorer will report cancelled test/s.
  3. Hacky - You cancel the test run and FCC does not cancel coverage as it currently does.
  4. You do not run the test with the ui from test explorer but another.

1 Requires time and effort that I nor @FortuneN have at our disposal currently.

2 Is probably not possible. The interface that is provided to us does not have such functionality. We use reflection on the implementation to get the hidden information that we require. A quick look in vs and I do not see a cancellation method.

3 This can work but it is dependent upon the test/s being run from test explorer. For instance in a demo project with single test that starts the notepad process this does not work. If you add a dummy test with a Thread.Sleep of sufficient duration that is named to execute before the real test and you run both then there is sufficient time to cancel. Of course if you do not cancel then there will be two triggers if you do not disable FCC.

4 FCC just needs the hook to get the dll that needs coverage. It can get that from running any test. Choose a test that does not start notepad and if necessary create a dummy test. Of couse if you need to see your test passing you will have to run it and there will be 2 triggers.

For now your only option is option 4 and to disable FCC when you want to execute the test.

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

No branches or pull requests

2 participants