stryker-mutator / stryker-net

Mutation testing for .NET core and .NET framework!
https://stryker-mutator.io
Apache License 2.0
1.77k stars 184 forks source link

.NET Framework 4.7.2 Exception - Not enough information to troubleshoot #2028

Closed Christian-Oleson closed 3 months ago

Christian-Oleson commented 2 years ago

Describe the bug Styker is failing in a .NET Framework project. I do not have enough information to understand what the issue is nor to troubleshoot. I followed the docs found here:

Logs

dotnet tool run dotnet-stryker

   _____ _              _               _   _ ______ _______  
  / ____| |            | |             | \ | |  ____|__   __| 
 | (___ | |_ _ __ _   _| | _____ _ __  |  \| | |__     | |    
  \___ \| __| '__| | | | |/ / _ \ '__| | . ` |  __|    | |    
  ____) | |_| |  | |_| |   <  __/ |    | |\  | |____   | |    
 |_____/ \__|_|   \__, |_|\_\___|_| (_)|_| \_|______|  |_|    
                   __/ |                                      
                  |___/                                       

Version: 1.5.3
[15:14:07 INF] Identifying project to mutate.
[15:14:08 INF] Time Elapsed 00:00:01.6935843
Unhandled exception. System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.ThrowHelper.ThrowNoMatchException()
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
   at Stryker.Core.Initialisation.ProjectFileReader.SelectAnalyzerResult(IAnalyzerResults analyzerResults, String targetFramework) in /_/src/Stryker.Core/Stryker.Core/Initialisation/ProjectFileReader.cs:line 107
   at Stryker.Core.Initialisation.ProjectFileReader.AnalyzeProject(String projectFilePath, String solutionFilePath, String targetFramework) in /_/src/Stryker.Core/Stryker.Core/Initialisation/ProjectFileReader.cs:line 55
   at Stryker.Core.Initialisation.InputFileResolver.ResolveInput(StrykerOptions options) in /_/src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs:line 62
   at Stryker.Core.Initialisation.InitialisationProcess.Initialize(StrykerOptions options) in /_/src/Stryker.Core/Stryker.Core/Initialisation/InitialisationProcess.cs:line 64
   at Stryker.Core.Initialisation.ProjectMutator.MutateProject(StrykerOptions options, IReporter reporters) in /_/src/Stryker.Core/Stryker.Core/Initialisation/ProjectMutator.cs:line 30
   at Stryker.Core.Initialisation.ProjectOrchestrator.MutateProjects(StrykerOptions options, IReporter reporters)+MoveNext() in /_/src/Stryker.Core/Stryker.Core/Initialisation/ProjectOrchestrator.cs:line 61
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Stryker.Core.StrykerRunner.RunMutationTest(IStrykerInputs inputs, ILoggerFactory loggerFactory, IProjectOrchestrator projectOrchestrator) in /_/src/Stryker.Core/Stryker.Core/StrykerRunner.cs:line 58
   at Stryker.CLI.StrykerCli.RunStryker(IStrykerInputs inputs) in /_/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 93
   at Stryker.CLI.StrykerCli.<>c__DisplayClass10_0.<Run>b__0() in /_/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 68
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass143_0.<OnExecute>b__0(CancellationToken _)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Stryker.CLI.StrykerCli.Run(String[] args) in /_/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 74
   at Stryker.CLI.Program.Main(String[] args) in /_/src/Stryker.CLI/Stryker.CLI/Program.cs:line 14

Expected behavior A better handled exception so the user can understand what is occurring. I don't know where to start to troubleshoot based off of the message aside from the Stryker code.

Desktop (please complete the following information):

Additional context N/a

rouke-broersma commented 2 years ago

Looks like we were unable to analyze your project for some reason, resulting in a linq exception. We probably use SingleOrDefault somewhere where we did not expect to not get a result.

Christian-Oleson commented 2 years ago

Looks like we were unable to analyze your project for some reason, resulting in a linq exception. We probably use SingleOrDefault somewhere where we did not expect to not get a result.

Correct. Ideally, if we can get more information to display to the end-user, that will help troubleshoot. I've not gotten to the point yet where I've figured out what is going on. Even verbose logging is lacking in information.

Christian-Oleson commented 2 years ago

I think I have a fix for this at least: https://github.com/stryker-mutator/stryker-net/pull/2030

dupdob commented 2 years ago

The associated fix has been released. Is the problem still present?

Christian-Oleson commented 2 years ago

The associated fix has been released. Is the problem still present?

Technically, this is due to an issue with Buildalyzer not finding a valid MSBuild version to run mutation testing. So if Buidalyzer is having issues, it will still fail.

rouke-broersma commented 3 months ago

This might behave better with recent changes