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

System.IO.DirectoryNotFoundException after upgrade to System.IO.Abstractions.TestHelpers@2.1.0.230 #364

Closed
simondel opened this issue Oct 3, 2018 · 4 comments
Labels
state: needs discussion Issues that need further discussion

Comments

@simondel
Copy link

simondel commented Oct 3, 2018

After upgrading to System.IO.Abstractions.TestHelpers@2.1.0.230 we get the following error:

Starting test execution, please wait...
[xUnit.net 00:00:02.04]     Stryker.Core.UnitTest.MutationTest.MutationTestProcessTests.MutationTestProcess_MutateShouldWriteToDisk_IfCompilationIsSuccessful [FAIL]
Failed   Stryker.Core.UnitTest.MutationTest.MutationTestProcessTests.MutationTestProcess_MutateShouldWriteToDisk_IfCompilationIsSuccessful
Error Message:
 System.IO.DirectoryNotFoundException : Could not find a part of the path 'c\ExampleProject.Test\bin\Debug\netcoreapp2.0\ExampleProject.dll'.
Stack Trace:
   at System.IO.Abstractions.TestingHelpers.MockFile.Create(String path)
   at Stryker.Core.MutationTest.MutationTestProcess.Mutate() in C:\projects\stryker-net\src\Stryker.Core\Stryker.Core\MutationTest\MutationTestProcess.cs:line 78
   at Stryker.Core.UnitTest.MutationTest.MutationTestProcessTests.MutationTestProcess_MutateShouldWriteToDisk_IfCompilationIsSuccessful() in C:\projects\stryker-net\src\Stryker.Core\Stryker.Core.UnitTest\MutationTest\MutationTestProcessTests.cs:line 207
[06:21:53 ERR] The task PrintReferences was not found in your project file. Please add the task to ExampleProject.Test.csproj

The mock in question is created here: https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core.UnitTest/MutationTest/MutationTestProcessTests.cs#L181

And is the error probably occurs here:
https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/MutationTest/MutationTestProcess.cs#L78

Has something changed in the api with System.IO.Abstractions.TestHelpers@2.1.0.230?

@fgreinacher
Copy link
Contributor

fgreinacher commented Oct 4, 2018

@rkoeninger related to #327?

@simondel We are now a bit more restrictive on what can be at the beginning of a path - the exception mentions a path that starts with c\ - this is will probably be the issue here.

@fgreinacher fgreinacher added the state: needs discussion Issues that need further discussion label Oct 4, 2018
@rkoeninger
Copy link
Contributor

@fgreinacher Yes, I think this error would not have been raised before #327.

@simondel I think there's just a : missing from the test path on this line. Does adding the : fix it?

@simondel
Copy link
Author

simondel commented Oct 5, 2018

@fgreinacher @rkoeninger Thanks for the feedback! The path was indeed incorrect, but that did not fix the issue.

For now I just create the directory before using it. During a production run, the directory already exists.

I find it to be a bit strange that a directory should exist while using a Mock, but since my issue is now resolved, I'll close this issue.

@simondel simondel closed this as completed Oct 5, 2018
@jbaehr
Copy link

jbaehr commented Apr 2, 2019

@simondel The DirectoryNotFound exception is by design, see #227, to mirror the behavior of System.IO.
Previously all unit tests have been green (using the Mock) but it crashed in production (not using the mock but system.io)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs discussion Issues that need further discussion
Projects
None yet
Development

No branches or pull requests

4 participants