-
-
Notifications
You must be signed in to change notification settings - Fork 46
Description
Installed product versions
- Visual Studio: Microsoft Visual Studio Community 2019, Version 16.10.3
- This extension: 1.1.141
- Nunit 3.17.0
Description
FCC shows 0% code coverage. The test fixture is completely ignored.
Steps to recreate
The cause seems to be a line of code in the [Setup] method.
- Add a setup method to the test class
- Add
throw new Exception(). - Run test
- FCC removes all coverage and shows 0%.
Current behavior
- In the setup method I copied a file to the temporary folder to run some tests on this file.
- Once the situation occurred that the file was already in the temp folder and the test failed because of the exception during set up (because the file could not be copied since it was already there).
- Then FCC removed all coverage.
- When I comment that line of code out, FCC shows 53.7% coverage again.
- But that seems the only thing that works. This did not:
- Comment that line out, run a test, and remove the comment: did not work.
- Change the statement: e.g. I replace the constant path
const string BasePathwith the string "...\...\folderlocation": did not work.
I finally tracked the error down in my case. FCC seems to run the tests itself and causes an exception every time it runs the test because AppDomain.CurrentDomain.BaseDirectory seems to be different from the path of the testing environment.
[SetUp]
public void SetUp()
{
string BasePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\TestDataFiles"));
File.Copy(Path.Combine(BasePath, "RecipeFile.json"), Path.Combine(TestingPath, "RecipeFile.json"));
// ...FCC tries to copy the file from "[...]\bin\Debug\TestDataFiles" which does not work in my case. Consequence: every time the setup is called it ends in an exception. Hence, none of the tests succeeds and I get no coverage at all.
Expected behavior
Shouldn't I get the code coverage regardless of the fact that tests fail or succeed? And regardless of the place where the test fails, whether in the test method or in setup/teardown?
Notes
- The option RunWhenTestsFail is set to true.