stryker-mutator / stryker-net

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

Null reference exception if no test project in solution #2374

Closed akoken closed 1 year ago

akoken commented 1 year ago

Describe the bug If there is no test project in solution, Stryker throws null reference exception.

Logs Version: 3.4.0 [09:20:36 INF] Identifying projects to mutate in /builds/apigateway/ApiGateway.sln. This can take a while. [09:20:40 INF] Found 1 source projects [09:20:40 INF] Found 0 test projects [09:20:42 WRN] No test projects could be found for /builds/apigateway/src/ApiGateway/ApiGateway.csproj [09:20:42 INF] Time Elapsed 00:00:06.1619361 Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object. at Stryker.Core.StrykerRunner.RunMutationTest(IStrykerInputs inputs, ILoggerFactory loggerFactory, IProjectOrchestrator projectOrchestrator) at Stryker.CLI.StrykerCli.RunStryker(IStrykerInputs inputs) in /_/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 93 at Stryker.CLI.StrykerCli.<>cDisplayClass10_0.b_0() in //src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 68 at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>cDisplayClass143_0.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 Aborted (core dumped) ERROR: Job failed: exit code 134

Expected behavior If there is no test project in solution, it should skip running instead of throwing exception like other dotnet tools such as dotnet test.

Desktop (please complete the following information):

Additional context We have many projects using our CI/CD pipeline. Unfortunately some of them do not have any test project. Therefore they fail at mutation testing stage and exit.

richardwerkman commented 1 year ago

Huh, guess we never tested for that... I'll look into this tomorrow!

akoken commented 1 year ago

Considering all of its features, that is really a small flaw:) I appreciate the fantastic library.