question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Original project under test cannot be loaded" and "Unable to rollback mutation" when BuildOutputDir is changed relative to project dir

See original GitHub issue

Hello, I’m very new to using Stryker, and I’m having trouble that is likely related to the way my project puts build outputs outside of the source directory.

First, the error (and the request for me to create an issue):

[15:55:18 WRN] Original project under test C:\_git\VFSforGit\src\GVFS\BuildOutput\GVFS.Common\bin\AnyCPU\Debug\netcoreapp2.1\GVFS.Common.dll could not be loaded.
Embedded Resources might be missing.
System.IO.FileNotFoundException: Could not find file 'C:\_git\VFSforGit\src\GVFS\BuildOutput\GVFS.Common\bin\AnyCPU\Debug\netcoreapp2.1\GVFS.Common.dll'.
File name: 'C:\_git\VFSforGit\src\GVFS\BuildOutput\GVFS.Common\bin\AnyCPU\Debug\netcoreapp2.1\GVFS.Common.dll'
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
   at Stryker.Core.Initialisation.EmbeddedResourcesGenerator.LoadModule(String assemblyPath, ILogger logger) in C:\_git\stryker-net\src\Stryker.Core\Stryker.Core\Initialisation\EmbeddedResourcesGenerator.cs:line 42
[15:55:19 ERR] Unable to rollback mutation for node FileAttributes with error: Ambiguity between 'FileProperties.FileAttributes' and 'FileProperties.FileAttributes' (at C:\_git\VFSforGit\src\GVFS\GVFS.Common\FileSystem\FileProperties.cs, line: 7, col: 80).
[15:55:19 ERR] This should not happen, please report this as an issue on github with the previous error message.

Note that we use build variables to specify that SolutionDir would be C:\_git\VFSforGit\src and the build outputs should go in C:\_git\VFSforGit\BuildOutput, but here a couple of levels are skipped. This is likely due to the following lines in our .csproj settings:

    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..</SolutionDir>
    <BuildOutputDir>$(SolutionDir)\..\BuildOutput</BuildOutputDir>
    <PackagesDir>$(SolutionDir)\..\packages</PackagesDir>

This should make the SolutionDir be two levels above the project directory, and the build outputs go in ..\BuildOutputDir relative to that (which works during dotnet build). It appears that when Stryker mutates the code, something is going awry and causes some duplication of code.

My guess is that the mutated code is being placed in a deeper directory than normal, and hence the build outputs are being placed deeper in the source tree than usual. Alternatively, we are forcing the mutated outputs into the same spot as the non-mutated code and Stryker is trying to replace the mutation with the original binary. However, I’m not exactly sure how to resolve this issue.

I’d love to use Stryker to improve our test coverage, so I appreciate any pointers you can give.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
rouke-broersmacommented, Apr 26, 2019

Hey @derrickstolee ,

We have identified the issues with compiling your project, and it turned out to be a problem in our logic of loading shared projects which resulted in loading the complete GVFS codebase instead only the project under test. We have fixed this, and have identified another issue in the process. We do not version the assembly we write to disk, which fails 4 of the unit tests in the project because they rely on an assembly version. We are going to try and copy the original assembly version number when compiling our mutated assembly.

We have also identified a problem with finding the solution directory when no solution file is passed to stryker, this resulted in the build output folder not being correctly identified. For now I suggest you pass the GVFS sln file to stryker so the solution dir and build output dir are correctly found.

0reactions
derrickstoleecommented, May 13, 2019

Thanks for the ping @Mobrockers and for the detailed parameters. I ran the same thing and got a meaningful report! Of course, we need to do better with our unit tests, as very few mutations were killed.

Thanks so much for your help here!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mutation analysis problem - SonarQube - Sonar Community
I'm reusing the PITest reports. In sonarqube developer 7.5 is working. But recently I upgraded to 7.6. Still mutation giving same error.
Read more >
Pitest: How to set paths correct in different modules
I have a huge project for which I am testing mutation testing with Pitest. The project is in an OSGi form and having...
Read more >
Mutation Testing with Pitest – Part 2: SonarQube
We assume that the project has already created a basic Jenkinsfile to check it out from the version management, compile, run unit tests,...
Read more >
PIT and Sonar: Mutation in an unknown resource
Hello everybody, first of all I want to say that I am very happy to have found PIT which allows me to use...
Read more >
The Art of Unit Testing with Mutation and Static Code ...
Each mutation represents a single, well-defined change to the original code and simulates potential errors or defects. By identifying ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found