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

Running v3.8.0 with a baseline results in InvalidOperationException #2497

Closed timandella closed 1 year ago

timandella commented 1 year ago

Describe the bug We have a Azure DevOps pipeline that runs dotnet stryker against out unit test project. It ran successfully for version 3.7.1 of dotnet-stryker, but fails with an InvalidOperationException with v3.8.0

The (redacted) command that is being run is this

dotnet stryker -f ../../build/stryker/stryker-config.json --with-baseline:'test/branch' --version 'origin/master' --azure-fileshare-sas "XXX"

Logs The console log shows the following

2023-05-05T10:07:45.0717090Z ##[section]Starting: Run dotnet-stryker MyProject.Tests
2023-05-05T10:07:45.0721897Z ==============================================================================
2023-05-05T10:07:45.0722039Z Task         : PowerShell
2023-05-05T10:07:45.0722102Z Description  : Run a PowerShell script on Linux, macOS, or Windows
2023-05-05T10:07:45.0722212Z Version      : 2.220.0
2023-05-05T10:07:45.0722271Z Author       : Microsoft Corporation
2023-05-05T10:07:45.0722343Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2023-05-05T10:07:45.0722467Z ==============================================================================
2023-05-05T10:07:45.2140822Z Generating script.
2023-05-05T10:07:45.2149838Z ========================== Starting Command Output ===========================
2023-05-05T10:07:45.2176571Z [command]/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command . '/home/vsts/work/_temp/0d4bdd6b-9f0a-46b2-9847-d05cd0f7e1d0.ps1'
2023-05-05T10:07:45.8318734Z 
2023-05-05T10:07:45.8323534Z    _____ _              _               _   _ ______ _______  
2023-05-05T10:07:45.8324106Z   / ____| |            | |             | \ | |  ____|__   __| 
2023-05-05T10:07:45.8324302Z  | (___ | |_ _ __ _   _| | _____ _ __  |  \| | |__     | |    
2023-05-05T10:07:45.8324729Z   \___ \| __| '__| | | | |/ / _ \ '__| | . ` |  __|    | |    
2023-05-05T10:07:45.8324888Z   ____) | |_| |  | |_| |   <  __/ |    | |\  | |____   | |    
2023-05-05T10:07:45.8325144Z  |_____/ \__|_|   \__, |_|\_\___|_| (_)|_| \_|______|  |_|    
2023-05-05T10:07:45.8325284Z                    __/ |                                      
2023-05-05T10:07:45.8325416Z                   |___/                                       
2023-05-05T10:07:45.8325468Z 
2023-05-05T10:07:45.8325555Z 
2023-05-05T10:07:45.9453199Z Version: 3.8.0
2023-05-05T10:07:45.9453326Z 
2023-05-05T10:07:46.3362710Z [10:07:46 INF] Identifying project to mutate.
2023-05-05T10:08:05.6992396Z [10:08:05 INF] Found project /home/vsts/work/1/s/apps/MyProject/MyProject.csproj to mutate.
2023-05-05T10:08:05.7017828Z [10:08:05 INF] Building test project /home/vsts/work/1/s/apps/MyProject.Tests/MyProject.Tests.csproj (1/1)
2023-05-05T10:08:19.8533585Z [10:08:19 INF] Time Elapsed 00:00:33.6197147
2023-05-05T10:08:19.9505004Z Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
2023-05-05T10:08:19.9506406Z  ---> System.AggregateException: One or more errors occurred. (Each parameter in the deserialization constructor on type 'Stryker.Core.Reporters.Json.TestFiles.JsonTestFile' must bind to an object property or field on deserialization. Each parameter name must match with a property or field on the object. The match can be case-insensitive.)
2023-05-05T10:08:19.9507502Z  ---> System.InvalidOperationException: Each parameter in the deserialization constructor on type 'Stryker.Core.Reporters.Json.TestFiles.JsonTestFile' must bind to an object property or field on deserialization. Each parameter name must match with a property or field on the object. The match can be case-insensitive.
2023-05-05T10:08:19.9508095Z    at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ConstructorParameterIncompleteBinding(Type parentType)
2023-05-05T10:08:19.9508599Z    at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
2023-05-05T10:08:19.9509116Z    at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
2023-05-05T10:08:19.9509623Z    at System.Text.Json.Serialization.JsonDictionaryConverter`3.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TDictionary& value)
2023-05-05T10:08:19.9510935Z    at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
2023-05-05T10:08:19.9511406Z    at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
2023-05-05T10:08:19.9511878Z    at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
2023-05-05T10:08:19.9512381Z    at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
2023-05-05T10:08:19.9512845Z    at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
2023-05-05T10:08:19.9513301Z    at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
2023-05-05T10:08:19.9513801Z    at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonReaderState& readerState, Boolean isFinalBlock, ReadOnlySpan`1 buffer, JsonSerializerOptions options, ReadStack& state, JsonConverter converterBase)
2023-05-05T10:08:19.9514353Z    at System.Text.Json.JsonSerializer.ContinueDeserialize[TValue](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonConverter converter, JsonSerializerOptions options)
2023-05-05T10:08:19.9514852Z    at System.Text.Json.JsonSerializer.ReadAllAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken)
2023-05-05T10:08:19.9515281Z    at Stryker.Core.Reporters.Json.JsonReportSerialization.DeserializeJsonReportAsync(Stream stream)
2023-05-05T10:08:19.9515813Z    at Stryker.Core.Baseline.Providers.AzureFileShareBaselineProvider.Load(String version)
2023-05-05T10:08:19.9516162Z    at Stryker.Core.MutantFilters.BaselineMutantFilter.GetBaselineAsync()
2023-05-05T10:08:19.9516562Z    --- End of inner exception stack trace ---
2023-05-05T10:08:19.9516901Z    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
2023-05-05T10:08:19.9517270Z    at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
2023-05-05T10:08:19.9517580Z    at System.Threading.Tasks.Task`1.get_Result()
2023-05-05T10:08:19.9518008Z    at Stryker.Core.MutantFilters.BaselineMutantFilter..ctor(StrykerOptions options, IBaselineProvider baselineProvider, IGitInfoProvider gitInfoProvider, IBaselineMutantHelper baselineMutantHelper)
2023-05-05T10:08:19.9518478Z    at Stryker.Core.MutantFilters.MutantFilterFactory.DetermineEnabledMutantFilters(StrykerOptions options)
2023-05-05T10:08:19.9518973Z    at Stryker.Core.MutantFilters.MutantFilterFactory.Create(StrykerOptions options, MutationTestInput mutationTestInput, IDiffProvider diffProvider, IBaselineProvider baselineProvider, IGitInfoProvider gitInfoProvider)
2023-05-05T10:08:19.9519649Z    at Stryker.Core.MutationTest.CsharpMutationProcess..ctor(MutationTestInput mutationTestInput, IFileSystem fileSystem, StrykerOptions options, IMutantFilter mutantFilter, BaseMutantOrchestrator`1 orchestrator)
2023-05-05T10:08:19.9520127Z    at Stryker.Core.MutationTest.CsharpMutationProcess..ctor(MutationTestInput mutationTestInput, StrykerOptions options)
2023-05-05T10:08:19.9520545Z    --- End of inner exception stack trace ---
2023-05-05T10:08:19.9520925Z    at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
2023-05-05T10:08:19.9521370Z    at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
2023-05-05T10:08:19.9521740Z    at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
2023-05-05T10:08:19.9522149Z    at Stryker.Core.MutationTest.MutationTestProcess.<>c__DisplayClass9_0`1.<DeclareMutationProcessForLanguage>b__0(MutationTestInput x, StrykerOptions y)
2023-05-05T10:08:19.9522661Z    at Stryker.Core.MutationTest.MutationTestProcess.BuildMutationProcess()
2023-05-05T10:08:19.9523139Z    at Stryker.Core.MutationTest.MutationTestProcess..ctor(MutationTestInput input, StrykerOptions options, IReporter reporter, IMutationTestExecutor executor, IMutationProcess mutationProcess, ICoverageAnalyser coverageAnalyzer)
2023-05-05T10:08:19.9523666Z    at Stryker.Core.Initialisation.ProjectMutator.MutateProject(StrykerOptions options, IReporter reporters, IEnumerable`1 solutionProjects)
2023-05-05T10:08:19.9524093Z    at Stryker.Core.Initialisation.ProjectOrchestrator.MutateProjects(StrykerOptions options, IReporter reporters)+MoveNext()
2023-05-05T10:08:19.9524484Z    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
2023-05-05T10:08:19.9524832Z    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
2023-05-05T10:08:19.9525229Z    at Stryker.Core.StrykerRunner.RunMutationTest(IStrykerInputs inputs, ILoggerFactory loggerFactory, IProjectOrchestrator projectOrchestrator)
2023-05-05T10:08:19.9525673Z    at Stryker.CLI.StrykerCli.RunStryker(IStrykerInputs inputs) in /_/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 93
2023-05-05T10:08:19.9526095Z    at Stryker.CLI.StrykerCli.<>c__DisplayClass10_0.<Run>b__0() in /_/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 68
2023-05-05T10:08:19.9526524Z    at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass143_0.<OnExecute>b__0(CancellationToken _)
2023-05-05T10:08:19.9526957Z    at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
2023-05-05T10:08:19.9527341Z    at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
2023-05-05T10:08:19.9527807Z    at Stryker.CLI.StrykerCli.Run(String[] args) in /_/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 74
2023-05-05T10:08:19.9532940Z    at Stryker.CLI.Program.Main(String[] args) in /_/src/Stryker.CLI/Stryker.CLI/Program.cs:line 14
2023-05-05T10:08:21.2091756Z ##[error]PowerShell exited with code '1'.
2023-05-05T10:08:21.2101245Z ##[section]Finishing: Run dotnet-stryker MyProject.Tests

Expected behavior Stryker to complete without error

Desktop (please complete the following information):

Additional context No error occurs in 3.7.1

I am unable to recreate the error locally (with a Windows 10 OS)

Config file used is as follows:

{
    "stryker-config": {
        "baseline": {
            "provider": "AzureFileStorage",
            "azure-fileshare-url": "https://xxxx.file.core.windows.net/stryker/myproject"
        },
        "reporters": ["progress", "html", "cleartext"],
        "ignore-methods": ["ConfigureAwait"],
        "thresholds": {
            "high": 90,
            "low": 60,
            "break": 40
        },
        "coverage-analysis": "off",
        "mutate": ["**/*.cs", "!**/Program.cs", "!**/ServiceCollectionExtensions.cs", "!**/SwaggerConfigureOptions.cs"]
    }
}
rouke-broersma commented 1 year ago

Mhm looks like we accidentally created a breaking change on deserialization of json reports pre-testfile support. We should handle that gracefully. Thank you for the report!

On another note, once that's fixed you should be able to see your test results in the report :) 😅