private void HandleStrykerRunResult(IStrykerInputs inputs, StrykerRunResult result) { var logger = ApplicationLogging.LoggerFactory.CreateLogger <StrykerCli>(); if (double.IsNaN(result.MutationScore)) { logger.LogInformation("Stryker was unable to calculate a mutation score"); } else { logger.LogInformation("The final mutation score is {MutationScore:P2}", result.MutationScore); } if (result.ScoreIsLowerThanThresholdBreak()) { var thresholdBreak = (double)inputs.ValidateAll().Thresholds.Break / 100; logger.LogWarning("Final mutation score is below threshold break. Crashing..."); _console.WriteLine(); _console.MarkupLine($"[Red]The mutation score is lower than the configured break threshold of {thresholdBreak:P0}.[/]"); _console.MarkupLine(" [Red]Looks like you've got some work to do :smiling_face_with_halo:[/]"); ExitCode = ExitCodes.BreakThresholdViolated; } }
public void ScoreIsLowerThanThresholdBreak_ShouldReturnTrueWhen(double mutationScore, int thresholdBreak) { // Arrange var options = new StrykerOptions(thresholdHigh: 100, thresholdLow: 100, thresholdBreak: thresholdBreak); var runResult = new StrykerRunResult(options, mutationScore); // Act var scoreIsLowerThanThresholdBreak = runResult.ScoreIsLowerThanThresholdBreak(); // Assert scoreIsLowerThanThresholdBreak.ShouldBeTrue("because the mutation score is lower than the threshold break"); }
private void HandleStrykerRunResult(StrykerOptions options, StrykerRunResult result) { var logger = ApplicationLogging.LoggerFactory.CreateLogger <StrykerCLI>(); logger.LogInformation("The final mutation score is {MutationScore:P2}", result.MutationScore); if (result.ScoreIsLowerThanThresholdBreak()) { var thresholdBreak = (double)options.Thresholds.Break / 100; logger.LogWarning("Final mutation score is below threshold break. Crashing..."); Console.WriteLine(Output.Red($@" The mutation score is lower than the configured break threshold of {thresholdBreak:P0}. If you're running in a CI environment, this means your pipeline will now fail.")); Console.WriteLine(Output.Green(" Looks like you've got some work to do :)")); ExitCode = 1; } }
public void ScoreIsLowerThanThresholdBreak_ShouldReturnFalseWhen(double mutationScore, int thresholdBreak) { // Arrange var options = new StrykerOptions() { Thresholds = new Thresholds { High = 100, Low = 100, Break = thresholdBreak } }; var runResult = new StrykerRunResult(options, mutationScore); // Act var scoreIsLowerThanThresholdBreak = runResult.ScoreIsLowerThanThresholdBreak(); // Assert scoreIsLowerThanThresholdBreak.ShouldBeFalse("because the mutation score is higher than or equal to the threshold break"); }