stryker-mutator / stryker-net

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

Wrong Logging usage of unexpected test case in initial test run leads to stryker crash #2929

Closed Dirk-Peters-BF closed 1 month ago

Dirk-Peters-BF commented 2 months ago

Describe the bug Stryker run is aborted due to crash when a specific logging call in VsTestRunner.InitialTest Line 60 is used, when a new unexpected test case is detected in the intial test run.

Logs System.FormatException: Input string was not in a correct format. Failure to parse near offset 132. Expected an ASCII digit. 00:02:36  at System.Text.CompositeFormat.Parse(String format) 00:02:36  at Microsoft.Extensions.Logging.LogValuesFormatter..ctor(String format) 00:02:36  at Microsoft.Extensions.Logging.FormattedLogValues.<>c.<.ctor>b90(String f) 00:02:36  at Microsoft.Extensions.Logging.FormattedLogValues..ctor(String format, Object[] values) 00:02:36  at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, String message, Object[] args) 00:02:36  at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, String message, Object[] args) 00:02:36  at Microsoft.Extensions.Logging.LoggerExtensions.LogWarning(ILogger logger, String message, Object[] args) 00:02:36  at Stryker.Core.TestRunners.VsTest.VsTestRunner.InitialTest(IProjectAndTests project) in //src/Stryker.Core/Stryker.Core/TestRunners/VsTest/VsTestRunner.cs:line 60 00:02:36  at Stryker.Core.TestRunners.VsTest.VsTestRunnerPool.<>cDisplayClass12_0.b_0(VsTestRunner runner) in //src/Stryker.Core/Stryker.Core/TestRunners/VsTest/VsTestRunnerPool.cs:line 62 00:02:36  at Stryker.Core.TestRunners.VsTest.VsTestRunnerPool.RunThis[T](Func2 task) in /_/src/Stryker.Core/Stryker.Core/TestRunners/VsTest/VsTestRunnerPool.cs:line 103 00:02:36  at Stryker.Core.TestRunners.VsTest.VsTestRunnerPool.InitialTest(IProjectAndTests project) in /_/src/Stryker.Core/Stryker.Core/TestRunners/VsTest/VsTestRunnerPool.cs:line 62 00:02:36  at Stryker.Core.Initialisation.InitialTestProcess.InitialTest(StrykerOptions options, IProjectAndTests project, ITestRunner testRunner) in /_/src/Stryker.Core/Stryker.Core/Initialisation/InitialTestProcess.cs:line 35 00:02:36  at Stryker.Core.Initialisation.InitialisationProcess.InitialTest(StrykerOptions options, SourceProjectInfo projectInfo, ITestRunner testRunner, Boolean throwIfFails) in /_/src/Stryker.Core/Stryker.Core/Initialisation/InitialisationProcess.cs:line 128 00:02:36  at Stryker.Core.Initialisation.InitialisationProcess.GetMutationTestInputs(StrykerOptions options, IReadOnlyCollection1 projects, ITestRunner runner) in //src/Stryker.Core/Stryker.Core/Initialisation/InitialisationProcess.cs:line 106 00:02:36  at Stryker.Core.Initialisation.ProjectOrchestrator.MutateProjects(StrykerOptions options, IReporter reporters, ITestRunner runner) in //src/Stryker.Core/Stryker.Core/Initialisation/ProjectOrchestrator.cs:line 66 00:02:36  at Stryker.Core.StrykerRunner.RunMutationTest(IStrykerInputs inputs, ILoggerFactory loggerFactory, IProjectOrchestrator projectOrchestrator) in /_/src/Stryker.Core/Stryker.Core/StrykerRunner.cs:line 63

Expected behavior Stryker does not crash.

Desktop (please complete the following information):

Additional context Reason for abort is wrong usage of Microsoft Logging. String interpolation is used in conjunction with parameters. I can provide a fix myself, just need a ticket/justification.

dupdob commented 2 months ago

Thanks for reporting. I am working on a fix. Actually, the fix is simple, but I want to activate logging for unit tests to ensure there are no similar issues

Dirk-Peters-BF commented 2 months ago

As mentioned in the ticket, I am actually working on a fix myself but I am including other, similar logging calls. Not necessarily as severe but nevertheless not quite right. My Problem for the described problem is to reproduce outside of the original sources.

dupdob commented 2 months ago

Ok There is a unit test for this situation. Alas, it does not crash as logging is not enabled, so string formatting is simply skipped. So no exception

dupdob commented 2 months ago

Envoyé de mon iPhoneLe 2 mai 2024 à 18:06, Dirk-Peters-BF @.***> a écrit : As mentioned in the ticket, I am actually working on a fix myself but I am including other, similar logging calls. Not necessarily as severe but nevertheless not quite right. My Problem for the described problem is to reproduce outside of the original sources.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were assigned.Message ID: @.***>

Dirk-Peters-BF commented 2 months ago

The opened pull request contains the fix + some logging call harmonizing Since I touched a lot of files for this I'd understand if the pull request is rejected.