diff --git a/docs/configuration.md b/docs/configuration.md index 7de0fb9468..b75ee6719e 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -462,7 +462,7 @@ Config file: `"since": { }` Use git information to test only code changes since the given target. Stryker will only report on mutants within the changed code. All other mutants will not have a result. -If you wish to test only changed sources and tests but would like to have a complete mutation report see [with-baseline](#with-baseline-flag-committish). +If you wish to test only changed sources and tests but would like to have a complete mutation report see [with-baseline](#with-baseline-committish). Set the diffing target on the command line by passing a committish with the since flag in the format `--since:`. Set the diffing target in the config file by setting the [since target](#sincetarget-committish) option. @@ -502,36 +502,26 @@ Use [globbing syntax](https://en.wikipedia.org/wiki/Glob_(programming)) for wild ## Baseline -### `with-baseline` <`flag`> [`:committish`] +### `with-baseline` <`committish`> Default: `false` -Command line: `--with-baseline:feat-2` -Config file: `"baseline": { }` +Command line: `with-baseline feat-2` +Config file: `"baseline": { }` -Enabling `with-baseline` saves the mutation report to a storage location such as the filesystem. The mutation report is loaded at the start of the next mutation run. Any changed source code or unit test results in a reset of the mutants affected by the change. For unchanged mutants the previous result is reused. This feature expands on the [since](#since-flag-committish) feature by providing you with a full report after a partial mutation testrun. +Enabling `baseline`, alias `with-baseline`, saves the mutation report to a storage location such as the filesystem. The mutation report is loaded at the start of the next mutation run. Any changed source code or unit test results in a reset of the mutants affected by the change. For unchanged mutants the previous result is reused. This feature expands on the [since](#since-flag-committish) feature by providing you with a full report after a partial mutation testrun. The target of the baseline is a `committish` passed as an extra argument. The target determines which committish is used to establish or locate a baseline. The report name is based on the current branch name or the [project-info.version](#project-infoversion-committish). -Set the diffing target on the command line by passing a committish with the since flag. -Set the diffing target in the config file by setting the [since target](#sincetarget-committish) option. *\* The baseline and since features are mutually exclusive. This feature implicitly enables the [since](#since-flag-committish) feature for now.* -### `baseline.enabled` <`flag`> - -Default: `null` -Command line: `N/A` -Config file: `"baseline": { "enabled": false }` - -Enable or disable [with-baseline](#with-baseline-flag-committish). If the enabled property is not set but the `baseline` object exists in the config file it is assumed to be enabled. Use this option to (temporarily) disable `with-baseline` without having to delete the other baseline configuration. - ### `baseline.fallback-version` <`string`> Default: [since-target](#since-flag-committish) Command line: `N/A` -Config file: `"baseline": { "fallback-version": 'develop' }` +Config file: `"baseline": { "fallback-version": 'develop' }` -When [with-baseline](#with-baseline-flag-committish) is enabled and Stryker cannot find an existing report for the current branch the fallback version is used. When Stryker is still unable to find a baseline we will do a complete instead of partial testrun. The complete testrun will then be saved as the new baseline for the next mutation testrun. +When [with-baseline](#with-baseline-committish) is enabled and Stryker cannot find an existing report for the current branch the fallback version is used. When Stryker is still unable to find a baseline we will do a complete instead of partial testrun. The complete testrun will then be saved as the new baseline for the next mutation testrun. **Example**: ```json @@ -566,9 +556,9 @@ new baseline saved to: feat-2 Default: `Disk` Command line: `N/A` -Config file: `"baseline": { "provider": 'AzureFileStorage'}` +Config file: `"baseline": { "provider": 'AzureFileStorage'}` -Sets the storage provider for the baseline used by [with-baseline](#with-baseline-flag-committish). By default this is set to disk, when the dashboard [reporter](#reporter-string) is enabled this is automatically set to Dashboard. +Sets the storage provider for the baseline used by [with-baseline](#with-baseline-committish). By default this is set to disk, when the dashboard [reporter](#reporter-string) is enabled this is automatically set to Dashboard. Supported storage providers are: @@ -611,6 +601,14 @@ Allowed permissions: `Read`, `Write`, `Create` For more information on how to configure a SAS check the [Azure documentation](https://docs.microsoft.com/en-us/azure/storage/common/storage-sas-overview). +### `baseline recreate` + +Default: `false` +Command line: `with-baseline main recreate` +Config file: `N/A` + +Sometimes your baseline can get corrupted or out of touch with reality. In that case the baseline can be recreated using this command. This will test all mutations in your project and save the result as the new baseline. + ## Troubleshooting ### `verbosity` <`log-level`> @@ -630,7 +628,7 @@ All available loglevels are ### `log-to-file` <`flag`> -Default: `false` +Default: `false` Command line: `[-L|--log-to-file]` Config file: `N/A` diff --git a/docs/stryker-in-pipeline.md b/docs/stryker-in-pipeline.md index 861451f828..e64276978a 100644 --- a/docs/stryker-in-pipeline.md +++ b/docs/stryker-in-pipeline.md @@ -48,22 +48,39 @@ dotnet stryker --break-at 80 Dashboard compare is very useful when running stryker in pipelines because it cuts down on the total runtime by only testing mutations that have changed compared to for example master The following minimal steps are needed to use dashboard compare -1. Enable --with-baseline and choose the comparison target -1. Choose a storage provider (Dashboard for public projects or Azure File Share for private projects) +1. Enable [with-baseline](https://stryker-mutator.io/docs/stryker-net/configuration#with-baseline-committish) +1. Choose a target branch or commit, as the source of the baseline (usually current branch in your pull request) +1. Choose a [storage provider](https://stryker-mutator.io/docs/stryker-net/configuration#baselineprovider-string) (Dashboard for public projects or Azure File Share for private projects) 1. Set up authentication for the chosen storage provider -1. Set --version to the name of the source branch (usually current branch) 1. Set any other options needed for your chosen storage provider (see: [storage provider docs](https://stryker-mutator.io/docs/stryker-net/configuration#baselineprovider-string)) -Example for azure devops with dashboard storage provider: +_Example for azure devops with dashboard storage provider:_ ``` -dotnet stryker --with-baseline:$(System.PullRequest.TargetBranch) --dashboard-api-key $(Stryker.Dashboard.Api.Key) --version $(System.PullRequest.SourceBranch) +dotnet stryker with-baseline $(System.PullRequest.TargetBranch) --dashboard-api-key $(Stryker.Dashboard.Api.Key) --version $(System.PullRequest.SourceBranch) ``` ```json { "stryker-config": { "baseline": { - "provider": "Dashboard" + "provider": "Dashboard", + "fallback-version": "main" + } + } +} +``` + +_Example for azure devops with azure fileshare storage provider:_ +``` +dotnet stryker with-baseline $(System.PullRequest.TargetBranch) --azure-fileshare-sas $(Stryker.Azure.Fileshare.SAS) +``` + +```json +{ + "stryker-config": { + "baseline": { + "provider": "AzureFileStorage", + "fallback-version": "main" } } } diff --git a/src/Stryker.CLI/Stryker.CLI.UnitTest/ConfigBuilderTests.cs b/src/Stryker.CLI/Stryker.CLI.UnitTest/ConfigBuilderTests.cs index 79ee2274bc..0e1181acd6 100644 --- a/src/Stryker.CLI/Stryker.CLI.UnitTest/ConfigBuilderTests.cs +++ b/src/Stryker.CLI/Stryker.CLI.UnitTest/ConfigBuilderTests.cs @@ -99,7 +99,7 @@ private static Mock GetMockInputs() inputs.Setup(x => x.MutateInput).Returns(new MutateInput()); inputs.Setup(x => x.MutationLevelInput).Returns(new MutationLevelInput()); inputs.Setup(x => x.SinceInput).Returns(new SinceInput()); - inputs.Setup(x => x.WithBaselineInput).Returns(new WithBaselineInput()); + inputs.Setup(x => x.BaselineEnabledInput).Returns(new BaselineEnabledInput()); inputs.Setup(x => x.OpenReportInput).Returns(new OpenReportInput()); inputs.Setup(x => x.ReportersInput).Returns(new ReportersInput()); inputs.Setup(x => x.ProjectVersionInput).Returns(new ProjectVersionInput()); diff --git a/src/Stryker.CLI/Stryker.CLI.UnitTest/StrykerCLITests.cs b/src/Stryker.CLI/Stryker.CLI.UnitTest/StrykerCLITests.cs index f20f766d6e..ba2561e672 100644 --- a/src/Stryker.CLI/Stryker.CLI.UnitTest/StrykerCLITests.cs +++ b/src/Stryker.CLI/Stryker.CLI.UnitTest/StrykerCLITests.cs @@ -59,7 +59,7 @@ public void ShouldDisplayInfoOnHelp() var expected = @"Stryker: Stryker mutator for .Net -Stryker mutator for .Net +The mutation test framework for .Net Usage: Stryker [command] [options] @@ -413,7 +413,7 @@ public void ShouldSupplyWithBaselineWhenPassed(params string[] argName) _strykerRunnerMock.VerifyAll(); - _inputs.WithBaselineInput.SuppliedInput.Value.ShouldBeTrue(); + _inputs.BaselineEnabledInput.SuppliedInput.Value.ShouldBeTrue(); } [Theory] diff --git a/src/Stryker.CLI/Stryker.CLI.UnitTest/filled-stryker-config.json b/src/Stryker.CLI/Stryker.CLI.UnitTest/filled-stryker-config.json index e520311747..95dcfca6c8 100644 --- a/src/Stryker.CLI/Stryker.CLI.UnitTest/filled-stryker-config.json +++ b/src/Stryker.CLI/Stryker.CLI.UnitTest/filled-stryker-config.json @@ -49,7 +49,6 @@ "module": "cli" }, "baseline": { - "enabled": false, "fallback-version": "master", "azure-fileshare-url": "", "provider": "" diff --git a/src/Stryker.CLI/Stryker.CLI.UnitTest/filled-stryker-config.yaml b/src/Stryker.CLI/Stryker.CLI.UnitTest/filled-stryker-config.yaml index e6d4c552e5..cc4efec953 100644 --- a/src/Stryker.CLI/Stryker.CLI.UnitTest/filled-stryker-config.yaml +++ b/src/Stryker.CLI/Stryker.CLI.UnitTest/filled-stryker-config.yaml @@ -39,7 +39,6 @@ stryker-config: version: master module: cli baseline: - enabled: false fallback-version: master azure-fileshare-url: '' provider: '' diff --git a/src/Stryker.CLI/Stryker.CLI.UnitTest/packages.lock.json b/src/Stryker.CLI/Stryker.CLI.UnitTest/packages.lock.json index c5caed86ce..65bd08da84 100644 --- a/src/Stryker.CLI/Stryker.CLI.UnitTest/packages.lock.json +++ b/src/Stryker.CLI/Stryker.CLI.UnitTest/packages.lock.json @@ -1633,8 +1633,8 @@ "ShellProgressBar": "[5.2.0, )", "Spectre.Console": "[0.49.1, )", "Spectre.Console.Analyzer": "[0.49.1, )", - "Stryker.DataCollector": "[4.0.6, )", - "Stryker.RegexMutators": "[4.0.6, )", + "Stryker.DataCollector": "[1.0.0, )", + "Stryker.RegexMutators": "[1.0.0, )", "TestableIO.System.IO.Abstractions.Wrappers": "[21.0.2, )" } }, diff --git a/src/Stryker.CLI/Stryker.CLI/CommandLineConfig/CommandLineConfigReader.cs b/src/Stryker.CLI/Stryker.CLI/CommandLineConfig/CommandLineConfigReader.cs index 87465424e6..daee12f312 100644 --- a/src/Stryker.CLI/Stryker.CLI/CommandLineConfig/CommandLineConfigReader.cs +++ b/src/Stryker.CLI/Stryker.CLI/CommandLineConfig/CommandLineConfigReader.cs @@ -34,6 +34,8 @@ public void RegisterInitCommand(CommandLineApplication app, IFileSystem fileSyst { RegisterCliInputs(initCommandApp); + initCommandApp.HelpOption(); + initCommandApp.OnExecute(() => { _console.WriteLine($"Initializing new config file."); @@ -68,6 +70,44 @@ public void RegisterInitCommand(CommandLineApplication app, IFileSystem fileSyst }); } + public void RegisterBaselineCommand(CommandLineApplication app, IStrykerInputs inputs, string[] args, StrykerCli strykerCli) + { + app.Command("baseline", baselineCmd => + { + baselineCmd.AddName("with-baseline"); + RegisterCliInputs(baselineCmd); + + var committishArg = baselineCmd.Argument("target", "The target to compare with the current version. This can be any version indicator like branch, tag, commit-id or semver."); + committishArg.IsRequired(true, "The target argument is required. Example: dotnet stryker baseline main."); + baselineCmd.HelpOption(); + + baselineCmd.OnExecute(() => + { + inputs.BaselineTargetInput.SuppliedInput = committishArg.Value; + inputs.BaselineEnabledInput.SuppliedInput = true; + baselineCmd.Description = "Starts a stryker run based on the results of a previous run."; + return strykerCli.StartApp(inputs, args, app, this); + }); + + baselineCmd.Command("recreate", createCmd => + { + RegisterCliInputs(createCmd); + + createCmd.HelpOption(); + + createCmd.OnExecute(() => + { + inputs.BaselineTargetInput.SuppliedInput = committishArg.Value; + inputs.BaselineEnabledInput.SuppliedInput = true; + createCmd.Description = "Creates a new baseline by doing a full stryker run"; + // Enable recreate + inputs.BaselineRecreateEnabledInput.SuppliedInput = true; + return strykerCli.StartApp(inputs, args, app, this); + }); + }); + }); + } + public CommandOption GetConfigFileOption(string[] args, CommandLineApplication app) { var commands = app.Parse(args); @@ -146,8 +186,8 @@ private static void HandleSingleOrNoValue(IInput strykerInput, CommandOption cli inputs.SinceTargetInput.SuppliedInput = cliInput.Value(); break; - case WithBaselineInput withBaselineInput: - withBaselineInput.SuppliedInput = true; + case BaselineEnabledInput baselineEnabledInput: + baselineEnabledInput.SuppliedInput = true; inputs.SinceTargetInput.SuppliedInput = cliInput.Value(); break; @@ -183,7 +223,7 @@ private void PrepareCliOptions(IStrykerInputs inputs) AddCliInput(inputs.MutateInput, "mutate", "m", optionType: CommandOptionType.MultipleValue, argumentHint: "glob-pattern", category: InputCategory.Mutation); AddCliInput(inputs.MutationLevelInput, "mutation-level", "l", category: InputCategory.Mutation); AddCliInput(inputs.SinceInput, "since", "", optionType: CommandOptionType.SingleOrNoValue, argumentHint: "committish", category: InputCategory.Mutation); - AddCliInput(inputs.WithBaselineInput, "with-baseline", "", optionType: CommandOptionType.SingleOrNoValue, argumentHint: "committish", category: InputCategory.Mutation); + AddCliInput(inputs.BaselineEnabledInput, "with-baseline", "", optionType: CommandOptionType.SingleOrNoValue, argumentHint: "committish", category: InputCategory.Mutation); // Category: Reporting AddCliInput(inputs.OpenReportInput, "open-report", "o", CommandOptionType.SingleOrNoValue, argumentHint: "report-type", category: InputCategory.Reporting); AddCliInput(inputs.ReportersInput, "reporter", "r", optionType: CommandOptionType.MultipleValue, category: InputCategory.Reporting); @@ -196,7 +236,7 @@ private void PrepareCliOptions(IStrykerInputs inputs) AddCliInput(inputs.DevModeInput, "dev-mode", null, optionType: CommandOptionType.NoValue, category: InputCategory.Misc); } - private void RegisterCliInput(CommandLineApplication app, CliInput option) + public void RegisterCliInput(CommandLineApplication app, CliInput option) { var argumentHint = option.OptionType switch { @@ -231,7 +271,7 @@ private CliInput AddCliOnlyInput(string argumentName, string argumentShortName, return cliOption; } - private void AddCliInput(IInput input, string argumentName, string argumentShortName, + public void AddCliInput(IInput input, string argumentName, string argumentShortName, CommandOptionType optionType = CommandOptionType.SingleValue, InputCategory category = InputCategory.Generic, string argumentHint = null) { var cliOption = new CliInput diff --git a/src/Stryker.CLI/Stryker.CLI/CommandLineConfig/GroupedHelpTextGenerator.cs b/src/Stryker.CLI/Stryker.CLI/CommandLineConfig/GroupedHelpTextGenerator.cs index b167a9ee63..294de1dda7 100644 --- a/src/Stryker.CLI/Stryker.CLI/CommandLineConfig/GroupedHelpTextGenerator.cs +++ b/src/Stryker.CLI/Stryker.CLI/CommandLineConfig/GroupedHelpTextGenerator.cs @@ -8,7 +8,7 @@ namespace Stryker.CLI { - [ExcludeFromCodeCoverage] // Not worth the effort to test + [ExcludeFromCodeCoverage(Justification = "Not worth the effort to test")] internal class GroupedHelpTextGenerator : DefaultHelpTextGenerator { protected override void GenerateOptions(CommandLineApplication application, TextWriter output, IReadOnlyList visibleOptions, int firstColumnWidth) diff --git a/src/Stryker.CLI/Stryker.CLI/FileBasedInput.cs b/src/Stryker.CLI/Stryker.CLI/FileBasedInput.cs index 2736b8ef1c..f65451876f 100644 --- a/src/Stryker.CLI/Stryker.CLI/FileBasedInput.cs +++ b/src/Stryker.CLI/Stryker.CLI/FileBasedInput.cs @@ -115,9 +115,6 @@ public class Since : IExtraData public class Baseline : IExtraData { - [JsonPropertyName("enabled")] - public bool? Enabled { get; init; } - [JsonPropertyName("provider")] public string Provider { get; init; } diff --git a/src/Stryker.CLI/Stryker.CLI/FileConfigReader.cs b/src/Stryker.CLI/Stryker.CLI/FileConfigReader.cs index 0be59def0c..3be31d968e 100644 --- a/src/Stryker.CLI/Stryker.CLI/FileConfigReader.cs +++ b/src/Stryker.CLI/Stryker.CLI/FileConfigReader.cs @@ -33,15 +33,11 @@ public static void DeserializeConfig(string configFilePath, IStrykerInputs input if (config.Baseline is not null) { - // Baseline is implicitly enabled when the object exists in the file config - inputs.WithBaselineInput.SuppliedInput = config.Baseline.Enabled ?? true; - inputs.BaselineProviderInput.SuppliedInput = config.Baseline.Provider; inputs.FallbackVersionInput.SuppliedInput = config.Baseline.FallbackVersion; inputs.AzureFileStorageUrlInput.SuppliedInput = config.Baseline.AzureFileShareUrl; } - inputs.CoverageAnalysisInput.SuppliedInput = config.CoverageAnalysis; inputs.DisableBailInput.SuppliedInput = config.DisableBail; inputs.DisableMixMutantsInput.SuppliedInput = config.DisableMixMutants; diff --git a/src/Stryker.CLI/Stryker.CLI/FileConfigWriter.cs b/src/Stryker.CLI/Stryker.CLI/FileConfigWriter.cs index 4f6e2b2668..aff06d6875 100644 --- a/src/Stryker.CLI/Stryker.CLI/FileConfigWriter.cs +++ b/src/Stryker.CLI/Stryker.CLI/FileConfigWriter.cs @@ -20,7 +20,6 @@ private static FileBasedInputOuter CreateConfig(IStrykerInputs inputs) { Baseline = new Baseline { - Enabled = inputs.WithBaselineInput.SuppliedInput ?? inputs.WithBaselineInput.Default, Provider = inputs.BaselineProviderInput.SuppliedInput ?? inputs.BaselineProviderInput.Default, FallbackVersion = inputs.FallbackVersionInput.SuppliedInput ?? inputs.FallbackVersionInput.Default, AzureFileShareUrl = inputs.AzureFileStorageUrlInput.SuppliedInput ?? inputs.AzureFileStorageUrlInput.Default, diff --git a/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs b/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs index 93ec8f3c53..8cb94f7bf8 100644 --- a/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs +++ b/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs @@ -50,7 +50,7 @@ public int Run(string[] args) { Name = "Stryker", FullName = "Stryker: Stryker mutator for .Net", - Description = "Stryker mutator for .Net", + Description = "The mutation test framework for .Net", ExtendedHelpText = "Welcome to Stryker for .Net! Run dotnet stryker to kick off a mutation test run", HelpTextGenerator = new GroupedHelpTextGenerator() }; @@ -61,18 +61,11 @@ public int Run(string[] args) cmdConfigReader.RegisterCommandLineOptions(app, inputs); cmdConfigReader.RegisterInitCommand(app, _fileSystem, inputs, args); + cmdConfigReader.RegisterBaselineCommand(app, inputs, args, this); app.OnExecute(() => { - // app started - PrintStrykerASCIIName(); - - _configReader.Build(inputs, args, app, cmdConfigReader); - _loggingInitializer.SetupLogOptions(inputs); - - PrintStrykerVersionInformationAsync(); - RunStryker(inputs); - return ExitCode; + return StartApp(inputs, args, app, cmdConfigReader); }); try @@ -87,9 +80,9 @@ public int Run(string[] args) { Console.Error.WriteLine(); Console.Error.WriteLine("Did you mean this?"); - foreach(var match in uex.NearestMatches) + foreach (var nearMatch in uex.NearestMatches) { - Console.Error.WriteLine(" " + match); + Console.Error.WriteLine(" " + nearMatch); } } @@ -97,6 +90,19 @@ public int Run(string[] args) } } + internal int StartApp(IStrykerInputs inputs, string[] args, CommandLineApplication app, CommandLineConfigReader cmdConfigReader) + { + // app started + PrintStrykerASCIIName(); + + _configReader.Build(inputs, args, app, cmdConfigReader); + _loggingInitializer.SetupLogOptions(inputs); + + PrintStrykerVersionInformationAsync(); + RunStryker(inputs); + return ExitCode; + } + private void RunStryker(IStrykerInputs inputs) { var result = _stryker.RunMutationTest(inputs, ApplicationLogging.LoggerFactory); diff --git a/src/Stryker.CLI/Stryker.CLI/packages.lock.json b/src/Stryker.CLI/Stryker.CLI/packages.lock.json index 7453111d47..d876a170ce 100644 --- a/src/Stryker.CLI/Stryker.CLI/packages.lock.json +++ b/src/Stryker.CLI/Stryker.CLI/packages.lock.json @@ -1473,8 +1473,8 @@ "ShellProgressBar": "[5.2.0, )", "Spectre.Console": "[0.49.1, )", "Spectre.Console.Analyzer": "[0.49.1, )", - "Stryker.DataCollector": "[4.0.6, )", - "Stryker.RegexMutators": "[4.0.6, )", + "Stryker.DataCollector": "[1.0.0, )", + "Stryker.RegexMutators": "[1.0.0, )", "TestableIO.System.IO.Abstractions.Wrappers": "[21.0.2, )" } }, diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/MutantFilters/BaselineMutantFilterTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/MutantFilters/BaselineMutantFilterTests.cs index 6e96db01a7..0068537537 100644 --- a/src/Stryker.Core/Stryker.Core.UnitTest/MutantFilters/BaselineMutantFilterTests.cs +++ b/src/Stryker.Core/Stryker.Core.UnitTest/MutantFilters/BaselineMutantFilterTests.cs @@ -46,7 +46,7 @@ public void GetBaseline_UsesBaselineFallbackVersion_WhenReportForCurrentVersionN var options = new StrykerOptions() { - WithBaseline = true, + BaselineEnabled = true, DashboardApiKey = "Acces_Token", ProjectName = "github.com/JohnDoe/project", ProjectVersion = "version/human/readable", @@ -83,7 +83,7 @@ public void GetBaseline_UsesFallbackVersion_WhenBaselineFallbackVersionNotFound( var options = new StrykerOptions() { - WithBaseline = true, + BaselineEnabled = true, DashboardApiKey = "Acces_Token", ProjectName = "github.com/JohnDoe/project", ProjectVersion = "version/human/readable", @@ -121,7 +121,7 @@ public void GetBaseline_UsesCurrentVersionReport_IfReportExists() var options = new StrykerOptions() { - WithBaseline = true, + BaselineEnabled = true, DashboardApiKey = "Access_Token", ProjectName = "github.com/JohnDoe/project", ProjectVersion = "version/human/readable", @@ -155,7 +155,7 @@ public void FilterMutantsReturnAllMutantsWhenCompareToDashboardEnabledAndBaselin var options = new StrykerOptions() { - WithBaseline = true, + BaselineEnabled = true, ProjectVersion = "version", }; @@ -187,7 +187,7 @@ public void FilterMutants_WhenMutantSourceCodeIsNull_MutantIsReturned() var options = new StrykerOptions() { - WithBaseline = true, + BaselineEnabled = true, ProjectVersion = "version", }; var file = new CsharpFileLeaf @@ -239,7 +239,7 @@ public void FilterMutants_WhenMutantMatchesSourceCode_StatusIsSetToJsonMutant() var options = new StrykerOptions() { - WithBaseline = true, + BaselineEnabled = true, ProjectVersion = "version", }; var file = new CsharpFileLeaf @@ -302,7 +302,7 @@ public void FilterMutants_WhenMultipleMatchingMutants_ResultIsSetToNotRun() var options = new StrykerOptions() { - WithBaseline = true, + BaselineEnabled = true, ProjectVersion = "version", }; var file = new CsharpFileLeaf @@ -375,7 +375,7 @@ public void ShouldNotUpdateMutantsWithBaselineIfFileNotInBaseline() var options = new StrykerOptions { - WithBaseline = true, + BaselineEnabled = true, ProjectVersion = "version" }; diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/MutantFilters/MutantFilterFactoryTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/MutantFilters/MutantFilterFactoryTests.cs index c61788597a..b7e67b94df 100644 --- a/src/Stryker.Core/Stryker.Core.UnitTest/MutantFilters/MutantFilterFactoryTests.cs +++ b/src/Stryker.Core/Stryker.Core.UnitTest/MutantFilters/MutantFilterFactoryTests.cs @@ -112,7 +112,7 @@ public void MutantFilterFactory_Creates_ExcludeLinqExpressionFilter_When_Exclude public void MutantFilterFactory_Creates_DashboardMutantFilter_And_DiffMutantFilter_WithBaseline_Enabled() { var options = new StrykerOptions() { - WithBaseline = true, + BaselineEnabled = true, ProjectVersion = "foo" }; @@ -136,7 +136,7 @@ public void MutantFilterFactory_Creates_BlockMutantFilter_Last() var options = new StrykerOptions() { // These options are added here to make sure this test covers all branches in the source method. - WithBaseline = true, + BaselineEnabled = true, ExcludedLinqExpressions = new List { LinqExpression.Distinct diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/MutantFilters/SinceMutantFilterTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/MutantFilters/SinceMutantFilterTests.cs index 8b71a3b22f..5eedbf4a9e 100644 --- a/src/Stryker.Core/Stryker.Core.UnitTest/MutantFilters/SinceMutantFilterTests.cs +++ b/src/Stryker.Core/Stryker.Core.UnitTest/MutantFilters/SinceMutantFilterTests.cs @@ -233,7 +233,7 @@ public void FilterMutants_FiltersNoMutants_IfTestsChanged() var options = new StrykerOptions() { - WithBaseline = false, + BaselineEnabled = false, ProjectVersion = "version" }; @@ -277,7 +277,7 @@ public void Should_IgnoreMutants_WithoutCoveringTestsInfo_When_Tests_Have_Change var options = new StrykerOptions() { - WithBaseline = false, + BaselineEnabled = false, ProjectVersion = "version" }; @@ -308,7 +308,7 @@ public void Should_ReturnAllMutants_When_NonSourceCodeFile_In_Tests_Has_Changed( // Arrange var options = new StrykerOptions() { - WithBaseline = true, + BaselineEnabled = true, ProjectVersion = "version" }; diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/Mutators/NullCoalescingExpressionMutatorTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/Mutators/NullCoalescingExpressionMutatorTests.cs index 03b1f0675f..867cdafa0d 100644 --- a/src/Stryker.Core/Stryker.Core.UnitTest/Mutators/NullCoalescingExpressionMutatorTests.cs +++ b/src/Stryker.Core/Stryker.Core.UnitTest/Mutators/NullCoalescingExpressionMutatorTests.cs @@ -11,7 +11,7 @@ namespace Stryker.Core.UnitTest.Mutators public class NullCoalescingExpressionMutatorTests : TestBase { [Fact] - public void ShouldBeMutationLevelStandard() + public void ShouldBeMutationLevelBasic() { var target = new NullCoalescingExpressionMutator(); target.MutationLevel.ShouldBe(MutationLevel.Basic); diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/BaselineRecreateEnabledInputTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/BaselineRecreateEnabledInputTests.cs new file mode 100644 index 0000000000..8af7a7460b --- /dev/null +++ b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/BaselineRecreateEnabledInputTests.cs @@ -0,0 +1,37 @@ +using Shouldly; +using Stryker.Core.Options.Inputs; +using Xunit; + +namespace Stryker.Core.UnitTest.Options.Inputs; + +public class BaselineRecreateEnabledInputTests : TestBase +{ + [Fact] + public void ShouldHaveHelpText() + { + var target = new BaselineRecreateEnabledInput(); + target.HelpText.ShouldBe("When enabled a new baseline will be created by doing a full run and storing the mutation results. | default: 'False'"); + } + + [Fact] + public void ShouldHaveDefault() + { + var target = new BaselineRecreateEnabledInput { SuppliedInput = true }; + + var result = target.Validate(); + + target.Default.ShouldBeFalse(); + result.ShouldBeTrue(); + } + + [Fact] + public void ShouldHaveDefaultForDashboard() + { + var target = new BaselineRecreateEnabledInput { SuppliedInput = false }; + + var result = target.Validate(); + + target.Default.ShouldBeFalse(); + result.ShouldBeFalse(); + } +} diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/BaselineTargetInputTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/BaselineTargetInputTests.cs new file mode 100644 index 0000000000..0973a46ca9 --- /dev/null +++ b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/BaselineTargetInputTests.cs @@ -0,0 +1,52 @@ +using Shouldly; +using Stryker.Core.Exceptions; +using Stryker.Core.Options.Inputs; +using Xunit; + +namespace Stryker.Core.UnitTest.Options.Inputs; + +public class BaselineTargetInputTests : TestBase +{ + [Fact] + public void ShouldHaveHelpText() + { + var target = new BaselineTargetInput(); + target.HelpText.ShouldBe( + "The target branch/commit to compare with the current codebase when the baseline feature is enabled. | default: 'master'"); + } + + [Fact] + public void ShouldUseSuppliedInputWhenSinceEnabled() + { + var suppliedInput = "develop"; + var validatedBaselineBranch = + new BaselineTargetInput { SuppliedInput = suppliedInput }.Validate(sinceEnabled: true); + validatedBaselineBranch.ShouldBe(suppliedInput); + } + + [Fact] + public void ShouldUseDefaultWhenSinceEnabledAndInputNull() + { + var input = new BaselineTargetInput(); + var validatedBaselineBranch = input.Validate(sinceEnabled: true); + validatedBaselineBranch.ShouldBe(input.Default); + } + + [Fact] + public void MustNotBeEmptyStringWhenSinceEnabled() + { + var ex = Assert.Throws(() => + { + new BaselineTargetInput { SuppliedInput = "" }.Validate(sinceEnabled: true); + }); + ex.Message.ShouldBe("The baseline target cannot be empty when the since feature is enabled"); + } + + [Fact] + public void ShouldNotValidateBaselineTargetWhenSinceDisabled() + { + var input = new BaselineTargetInput { SuppliedInput = "develop" }; + var validatedBaselineBranch = input.Validate(sinceEnabled: false); + validatedBaselineBranch.ShouldBe(input.Default); + } +} diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/FallbackVersionInputTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/FallbackVersionInputTests.cs index c49c72d4e7..5ac3cbdfe1 100644 --- a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/FallbackVersionInputTests.cs +++ b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/FallbackVersionInputTests.cs @@ -22,7 +22,7 @@ public void ShouldNotValidate_IfNotEnabled() { var input = new FallbackVersionInput { SuppliedInput = "master" }; - var validatedInput = input.Validate(withBaseline: false, projectVersion: "master", sinceTarget: "master"); + var validatedInput = input.Validate(baselineEnabled: false, sinceTarget: "master"); validatedInput.ShouldBe(new SinceTargetInput().Default); } @@ -32,7 +32,7 @@ public void ShouldUseProvidedInputValue() { var input = new FallbackVersionInput { SuppliedInput = "development" }; - var validatedInput = input.Validate(withBaseline: true, projectVersion: "feat/feat4", sinceTarget: "master"); + var validatedInput = input.Validate(baselineEnabled: true, sinceTarget: "master"); validatedInput.ShouldBe("development"); } @@ -42,7 +42,7 @@ public void ShouldUseSinceTarget_IfNotExplicitlySet() { var input = new FallbackVersionInput(); - var validatedInput = input.Validate(withBaseline: true, projectVersion: "development", sinceTarget: "main"); + var validatedInput = input.Validate(baselineEnabled: true, sinceTarget: "main"); validatedInput.ShouldBe("main"); } diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/OpenReportEnabledInputTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/OpenReportEnabledInputTests.cs index c46a49a8bd..11d07dfd72 100644 --- a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/OpenReportEnabledInputTests.cs +++ b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/OpenReportEnabledInputTests.cs @@ -1,5 +1,4 @@ using Shouldly; -using Stryker.Core.Exceptions; using Stryker.Core.Options.Inputs; using Xunit; @@ -8,10 +7,10 @@ namespace Stryker.Core.UnitTest.Options.Inputs public class OpenReportEnabledInputTests : TestBase { [Fact] - public void ShouldHaveNoHelpText() + public void ShouldHaveHelpText() { var target = new OpenReportEnabledInput(); - target.HelpText.ShouldBe(@" | default: 'False'"); + target.HelpText.ShouldBe(@"When enabled the report will open automatically after stryker has generated the report. | default: 'False'"); } [Fact] diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/ProjectVersionInputTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/ProjectVersionInputTests.cs index 01ed0de5d2..69871cdb0e 100644 --- a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/ProjectVersionInputTests.cs +++ b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/ProjectVersionInputTests.cs @@ -22,7 +22,7 @@ public void ProjectVersion_UsesSuppliedInput_IfDashboardReporterEnabled() var suppliedInput = "test"; var input = new ProjectVersionInput { SuppliedInput = suppliedInput }; - var result = input.Validate(reporters: new[] { Reporter.Dashboard }, withBaseline: false); + var result = input.Validate(reporters: new[] { Reporter.Dashboard }, baselineEnabled: false); result.ShouldBe(suppliedInput); } @@ -32,7 +32,7 @@ public void ProjectVersion_UsesSuppliedInput_IfBaselineEnabled() var suppliedInput = "test"; var input = new ProjectVersionInput { SuppliedInput = suppliedInput }; - var result = input.Validate(reporters: Enumerable.Empty(), withBaseline: true); + var result = input.Validate(reporters: Enumerable.Empty(), baselineEnabled: true); result.ShouldBe(suppliedInput); } @@ -42,7 +42,7 @@ public void ProjectVersion_ShouldBeDefault_IfBaselineAndDashboardDisabled() var suppliedInput = "test"; var input = new ProjectVersionInput { SuppliedInput = suppliedInput }; - var result = input.Validate(reporters: Enumerable.Empty(), withBaseline: false); + var result = input.Validate(reporters: Enumerable.Empty(), baselineEnabled: false); result.ShouldBe(string.Empty); } @@ -51,7 +51,7 @@ public void ProjectVersion_ShouldBeDefault_IfDashboardEnabledAndSuppliedInputNul { var input = new ProjectVersionInput(); - var result = input.Validate(reporters: new[] { Reporter.Dashboard }, withBaseline: false); + var result = input.Validate(reporters: new[] { Reporter.Dashboard }, baselineEnabled: false); result.ShouldBe(string.Empty); } @@ -61,7 +61,7 @@ public void ProjectVersion_CannotBeEmpty_WhenBaselineEnabled() var input = new ProjectVersionInput(); var exception = Should.Throw(() => { - input.Validate(reporters: Enumerable.Empty(), withBaseline: true); + input.Validate(reporters: Enumerable.Empty(), baselineEnabled: true); }); exception.Message.ShouldBe("Project version cannot be empty when baseline is enabled"); diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/ReportersInputTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/ReportersInputTests.cs index bd4cd8db8d..c51b576e43 100644 --- a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/ReportersInputTests.cs +++ b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/ReportersInputTests.cs @@ -80,7 +80,7 @@ public void ShouldEnableBaselineReporterWhenWithBaselineEnabled() { var target = new ReportersInput { SuppliedInput = null }; - var validatedReporters = target.Validate(withBaseline: true); + var validatedReporters = target.Validate(baselineEnabled: true); validatedReporters.ShouldContain(Reporter.Baseline); } diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/SinceInputTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/SinceInputTests.cs index 41ce619db3..a42e81e6c0 100644 --- a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/SinceInputTests.cs +++ b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/SinceInputTests.cs @@ -19,7 +19,7 @@ public void ShouldBeEnabledWhenTrue() { var target = new SinceInput { SuppliedInput = true }; - var result = target.Validate(withBaseline: null); + var result = target.Validate(baselineEnabled: null); result.ShouldBeTrue(); } @@ -29,7 +29,7 @@ public void ShouldBeEnabledWhenTrueEvenIfWithBaselineFalse() { var target = new SinceInput { SuppliedInput = true }; - var result = target.Validate(withBaseline: false); + var result = target.Validate(baselineEnabled: false); result.ShouldBeTrue(); } @@ -39,7 +39,7 @@ public void ShouldProvideDefaultWhenNull() { var target = new SinceInput(); - var result = target.Validate(withBaseline: null); + var result = target.Validate(baselineEnabled: null); result.ShouldBe(target.Default.Value); } @@ -49,7 +49,7 @@ public void ShouldNotBeEnabledWhenFalse() { var target = new SinceInput { SuppliedInput = false }; - var result = target.Validate(withBaseline: null); + var result = target.Validate(baselineEnabled: null); result.ShouldBeFalse(); } @@ -57,7 +57,7 @@ public void ShouldNotBeEnabledWhenFalse() [Fact] public void ShouldBeImplicitlyEnabledWithBaseline() { - var sinceEnabled = new SinceInput().Validate(withBaseline: true); + var sinceEnabled = new SinceInput().Validate(baselineEnabled: true); sinceEnabled.ShouldBeTrue(); } @@ -67,7 +67,7 @@ public void ShouldNotBeAllowedToExplicitlyEnableWithBaseline() { var sinceEnabled = new SinceInput{SuppliedInput = true }; - var exception = Should.Throw(() => sinceEnabled.Validate(withBaseline: true)); + var exception = Should.Throw(() => sinceEnabled.Validate(baselineEnabled: true)); exception.Message.ShouldBe("The since and baseline features are mutually exclusive."); } } diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/SinceTargetInputTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/SinceTargetInputTests.cs index 9253d1ba22..0ee6dd025f 100644 --- a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/SinceTargetInputTests.cs +++ b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/SinceTargetInputTests.cs @@ -11,14 +11,16 @@ public class SinceTargetInputTests : TestBase public void ShouldHaveHelpText() { var target = new SinceTargetInput(); - target.HelpText.ShouldBe(@"The target branch/commit to compare with the current codebase when the since feature is enabled. | default: 'master'"); + target.HelpText.ShouldBe( + @"The target branch/commit to compare with the current codebase when the since feature is enabled. | default: 'master'"); } [Fact] public void ShouldUseSuppliedInputWhenSinceEnabled() { var suppliedInput = "develop"; - var validatedSinceBranch = new SinceTargetInput { SuppliedInput = suppliedInput }.Validate(sinceEnabled: true); + var validatedSinceBranch = + new SinceTargetInput { SuppliedInput = suppliedInput }.Validate(sinceEnabled: true); validatedSinceBranch.ShouldBe(suppliedInput); } @@ -43,8 +45,9 @@ public void MustNotBeEmptyStringWhenSinceEnabled() [Fact] public void ShouldNotValidateSinceTargetWhenSinceDisabled() { - var validatedSinceBranch = new SinceTargetInput { SuppliedInput = "develop" }.Validate(sinceEnabled: false); - validatedSinceBranch.ShouldBe("master"); + var input = new SinceTargetInput { SuppliedInput = "develop" }; + var validatedSinceBranch = input.Validate(sinceEnabled: false); + validatedSinceBranch.ShouldBe(input.Default); } } } diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/WithBaselineInputTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/WithBaselineInputTests.cs index 174c345e22..f3352a28ca 100644 --- a/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/WithBaselineInputTests.cs +++ b/src/Stryker.Core/Stryker.Core.UnitTest/Options/Inputs/WithBaselineInputTests.cs @@ -4,19 +4,19 @@ namespace Stryker.Core.UnitTest.Options.Inputs { - public class WithBaselineInputTests : TestBase + public class BaselineEnabledInputTests : TestBase { [Fact] public void ShouldHaveHelpText() { - var target = new WithBaselineInput(); + var target = new BaselineEnabledInput(); target.HelpText.ShouldBe(@"EXPERIMENTAL: Use results stored in stryker dashboard to only test new mutants. | default: 'False'"); } [Fact] public void ShouldBeEnabledWhenTrue() { - var target = new WithBaselineInput { SuppliedInput = true }; + var target = new BaselineEnabledInput { SuppliedInput = true }; var result = target.Validate(); @@ -26,7 +26,7 @@ public void ShouldBeEnabledWhenTrue() [Fact] public void ShouldProvideDefaultFalseWhenNull() { - var target = new WithBaselineInput { SuppliedInput = null }; + var target = new BaselineEnabledInput { SuppliedInput = null }; var result = target.Validate(); @@ -36,7 +36,7 @@ public void ShouldProvideDefaultFalseWhenNull() [Fact] public void ShouldNotBeEnabledWhenFalse() { - var target = new WithBaselineInput { SuppliedInput = false }; + var target = new BaselineEnabledInput { SuppliedInput = false }; var result = target.Validate(); diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/Options/StrykerInputsTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/Options/StrykerInputsTests.cs index 77c42f627d..d1f9bdc112 100644 --- a/src/Stryker.Core/Stryker.Core.UnitTest/Options/StrykerInputsTests.cs +++ b/src/Stryker.Core/Stryker.Core.UnitTest/Options/StrykerInputsTests.cs @@ -47,7 +47,7 @@ public class StrykerInputsTests : TestBase ThresholdBreakInput = new ThresholdBreakInput(), ThresholdHighInput = new ThresholdHighInput(), ThresholdLowInput = new ThresholdLowInput(), - WithBaselineInput = new WithBaselineInput(), + BaselineEnabledInput = new BaselineEnabledInput(), BreakOnInitialTestFailureInput = new BreakOnInitialTestFailureInput(), }; @@ -131,7 +131,7 @@ public void UsingDashboardBaselineStorageWithBaselineShouldEnableDashboardApiKey _target.DashboardApiKeyInput.SuppliedInput = "dashboard_api_key"; _target.ReportersInput.SuppliedInput = new[] { "html" }; _target.BaselineProviderInput.SuppliedInput = "dashboard"; - _target.WithBaselineInput.SuppliedInput = true; + _target.BaselineEnabledInput.SuppliedInput = true; _target.ProjectVersionInput.SuppliedInput = "develop"; var result = _target.ValidateAll(); @@ -145,7 +145,7 @@ public void NotUsingDashboardBaselineStorageWithBaselineOrDashboardReporterShoul _target.DashboardApiKeyInput.SuppliedInput = "dashboard_api_key"; _target.ReportersInput.SuppliedInput = new[] { "html" }; _target.BaselineProviderInput.SuppliedInput = "disk"; - _target.WithBaselineInput.SuppliedInput = true; + _target.BaselineEnabledInput.SuppliedInput = true; _target.ProjectVersionInput.SuppliedInput = "develop"; var result = _target.ValidateAll(); @@ -156,7 +156,7 @@ public void NotUsingDashboardBaselineStorageWithBaselineOrDashboardReporterShoul [Fact] public void WithBaselineAndSinceShouldBeMutuallyExclusive() { - _target.WithBaselineInput.SuppliedInput = true; + _target.BaselineEnabledInput.SuppliedInput = true; _target.SinceInput.SuppliedInput = true; var exception = Should.Throw(() => _target.ValidateAll()); @@ -167,7 +167,7 @@ public void WithBaselineAndSinceShouldBeMutuallyExclusive() public void WithBaselineShouldNotThrow_2743() // https://github.com/stryker-mutator/stryker-net/issues/2743 { _target.ProjectVersionInput.SuppliedInput = "1"; - _target.WithBaselineInput.SuppliedInput = true; + _target.BaselineEnabledInput.SuppliedInput = true; Should.NotThrow(() => _target.ValidateAll()); } @@ -175,14 +175,14 @@ public void WithBaselineShouldNotThrow_2743() // https://github.com/stryker-muta [Fact] public void BaseLineOptionsShouldBeSetToDefaultWhenBaselineIsDisabled() { - _target.WithBaselineInput.SuppliedInput = false; + _target.BaselineEnabledInput.SuppliedInput = false; _target.BaselineProviderInput.SuppliedInput = "azurefilestorage"; _target.AzureFileStorageSasInput.SuppliedInput = "sasCredential"; _target.AzureFileStorageUrlInput.SuppliedInput = "azureUrl"; var result = _target.ValidateAll(); - result.WithBaseline.ShouldBeFalse(); + result.BaselineEnabled.ShouldBeFalse(); result.BaselineProvider.ShouldBe(BaselineProvider.Disk); result.AzureFileStorageSas.ShouldBe(string.Empty); result.AzureFileStorageUrl.ShouldBe(string.Empty); diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/Reporters/BaselineReporterTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/Reporters/BaselineReporterTests.cs index ef41534666..271d3f126e 100644 --- a/src/Stryker.Core/Stryker.Core.UnitTest/Reporters/BaselineReporterTests.cs +++ b/src/Stryker.Core/Stryker.Core.UnitTest/Reporters/BaselineReporterTests.cs @@ -24,7 +24,7 @@ public void Doesnt_Use_ProjectVersion_When_CurrentBranch_Is_Not_Null() { ProjectVersion = "new-feature", SinceTarget = "master", - WithBaseline = true + BaselineEnabled = true }; gitInfoProvider.Setup(x => x.GetCurrentBranchName()).Returns("new-feature"); diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/packages.lock.json b/src/Stryker.Core/Stryker.Core.UnitTest/packages.lock.json index be18765c72..4670704f74 100644 --- a/src/Stryker.Core/Stryker.Core.UnitTest/packages.lock.json +++ b/src/Stryker.Core/Stryker.Core.UnitTest/packages.lock.json @@ -1609,8 +1609,8 @@ "ShellProgressBar": "[5.2.0, )", "Spectre.Console": "[0.49.1, )", "Spectre.Console.Analyzer": "[0.49.1, )", - "Stryker.DataCollector": "[4.0.6, )", - "Stryker.RegexMutators": "[4.0.6, )", + "Stryker.DataCollector": "[1.0.0, )", + "Stryker.RegexMutators": "[1.0.0, )", "TestableIO.System.IO.Abstractions.Wrappers": "[21.0.2, )" } }, diff --git a/src/Stryker.Core/Stryker.Core/Initialisation/ProjectOrchestrator.cs b/src/Stryker.Core/Stryker.Core/Initialisation/ProjectOrchestrator.cs index 2dd88d9f9f..c557db731c 100644 --- a/src/Stryker.Core/Stryker.Core/Initialisation/ProjectOrchestrator.cs +++ b/src/Stryker.Core/Stryker.Core/Initialisation/ProjectOrchestrator.cs @@ -76,7 +76,7 @@ public IEnumerable MutateProjects(StrykerOptions options, private void InitializeDashboardProjectInformation(StrykerOptions options, SourceProjectInfo projectInfo) { var dashboardReporterEnabled = options.Reporters.Contains(Reporter.Dashboard) || options.Reporters.Contains(Reporter.All); - var dashboardBaselineEnabled = options.WithBaseline && options.BaselineProvider == BaselineProvider.Dashboard; + var dashboardBaselineEnabled = options.BaselineEnabled && options.BaselineProvider == BaselineProvider.Dashboard; var requiresProjectInformation = dashboardReporterEnabled || dashboardBaselineEnabled; var missingProjectName = string.IsNullOrEmpty(options.ProjectName); var missingProjectVersion = string.IsNullOrEmpty(options.ProjectVersion); diff --git a/src/Stryker.Core/Stryker.Core/MutantFilters/BaselineMutantFilter.cs b/src/Stryker.Core/Stryker.Core/MutantFilters/BaselineMutantFilter.cs index 23887157f8..f59a63c00a 100644 --- a/src/Stryker.Core/Stryker.Core/MutantFilters/BaselineMutantFilter.cs +++ b/src/Stryker.Core/Stryker.Core/MutantFilters/BaselineMutantFilter.cs @@ -38,7 +38,7 @@ public BaselineMutantFilter(StrykerOptions options, IBaselineProvider baselinePr _options = options; - if (options.WithBaseline) + if (options.BaselineEnabled) { _baseline = GetBaselineAsync().Result; } @@ -48,7 +48,7 @@ public BaselineMutantFilter(StrykerOptions options, IBaselineProvider baselinePr public IEnumerable FilterMutants(IEnumerable mutants, IReadOnlyFileLeaf file, StrykerOptions options) { - if (options.WithBaseline) + if (options.BaselineEnabled) { if (_baseline == null) { @@ -118,6 +118,12 @@ private void SetMutantStatusToBaselineMutantStatus(JsonMutant baselineMutant, private async Task GetBaselineAsync() { + if (_options.RecreateBaseline) + { + _logger.LogInformation("Now running a complete test to establish a fresh baseline."); + + return null; + } var branchName = _gitInfoProvider.GetCurrentBranchName(); var baselineLocation = $"baseline/{branchName}"; diff --git a/src/Stryker.Core/Stryker.Core/MutantFilters/MutantFilterFactory.cs b/src/Stryker.Core/Stryker.Core/MutantFilters/MutantFilterFactory.cs index 11cf27a452..944730552e 100644 --- a/src/Stryker.Core/Stryker.Core/MutantFilters/MutantFilterFactory.cs +++ b/src/Stryker.Core/Stryker.Core/MutantFilters/MutantFilterFactory.cs @@ -42,12 +42,12 @@ private static IEnumerable DetermineEnabledMutantFilters(StrykerO new IgnoreBlockMutantFilter(), }; - if (options.WithBaseline) + if (options.BaselineEnabled) { enabledFilters.Add(new BaselineMutantFilter(options, _baselineProvider ?? BaselineProviderFactory.Create(options), _gitInfoProvider ?? new GitInfoProvider(options))); } - if (options.Since || options.WithBaseline) + if (options.Since || options.BaselineEnabled) { enabledFilters.Add(new SinceMutantFilter(_diffProvider ?? new GitDiffProvider(options, _input.TestRunner.GetTests(_input.SourceProjectInfo)))); } diff --git a/src/Stryker.Core/Stryker.Core/MutantFilters/SinceMutantFilter.cs b/src/Stryker.Core/Stryker.Core/MutantFilters/SinceMutantFilter.cs index b85a73ff85..6ad72666dd 100644 --- a/src/Stryker.Core/Stryker.Core/MutantFilters/SinceMutantFilter.cs +++ b/src/Stryker.Core/Stryker.Core/MutantFilters/SinceMutantFilter.cs @@ -26,26 +26,6 @@ public SinceMutantFilter(IDiffProvider diffProvider = null) _diffResult = diffProvider.ScanDiff(); _tests = diffProvider.Tests; - - if (_diffResult != null) - { - _logger.LogInformation("{ChangedFilesCount} files changed", (_diffResult.ChangedSourceFiles?.Count ?? 0) + (_diffResult.ChangedTestFiles?.Count ?? 0)); - - if (_diffResult.ChangedSourceFiles != null) - { - foreach (var changedFile in _diffResult.ChangedSourceFiles) - { - _logger.LogInformation("Changed file {ChangedFile}", changedFile); - } - } - if (_diffResult.ChangedTestFiles != null) - { - foreach (var changedFile in _diffResult.ChangedTestFiles) - { - _logger.LogInformation("Changed test file {ChangedFile}", changedFile); - } - } - } } public IEnumerable FilterMutants(IEnumerable mutants, IReadOnlyFileLeaf file, StrykerOptions options) @@ -54,14 +34,14 @@ public IEnumerable FilterMutants(IEnumerable mutants, IReadOnlyF IEnumerable filteredMutants; // A non-csharp file is flagged by the diff result as modified. We cannot determine which mutants will be affected by this, thus all mutants have to be tested. - if (_diffResult.ChangedTestFiles is { } && _diffResult.ChangedTestFiles.Any(x => !x.EndsWith(".cs"))) + if (_diffResult.ChangedTestFiles is not null && _diffResult.ChangedTestFiles.Any(x => !x.EndsWith(".cs"))) { _logger.LogDebug("Returning all mutants in {RelativePath} because a non-source file is modified", file.RelativePath); return SetMutantStatusForNonCSharpFileChanged(mutants); } // If the diff result flags this file as modified, we want to run all mutants again - if (_diffResult.ChangedSourceFiles != null && _diffResult.ChangedSourceFiles.Contains(file.FullPath)) + if (_diffResult.ChangedSourceFiles is not null && _diffResult.ChangedSourceFiles.Contains(file.FullPath)) { _logger.LogDebug("Returning all mutants in {RelativePath} because the file is modified", file.RelativePath); return SetMutantStatusForFileChanged(mutants); @@ -73,14 +53,41 @@ public IEnumerable FilterMutants(IEnumerable mutants, IReadOnlyF // If any of the tests have been changed, we want to return all mutants covered by these testfiles. // Only check for changed c# files. Other files have already been handled. - if (_diffResult.ChangedTestFiles != null && _diffResult.ChangedTestFiles.Any(file => file.EndsWith(".cs"))) + if (_diffResult.ChangedTestFiles is not null && _diffResult.ChangedTestFiles.Any(file => file.EndsWith(".cs"))) { filteredMutants = ResetMutantStatusForChangedTests(mutants); } + LogChangedFiles(options); + return filteredMutants; } + private void LogChangedFiles(StrykerOptions options) + { + if (_diffResult != null && !options.RecreateBaseline) + { + _logger.LogInformation("{ChangedFilesCount} files changed", (_diffResult.ChangedSourceFiles?.Count ?? 0) + (_diffResult.ChangedTestFiles?.Count ?? 0)); + + if (_diffResult.ChangedSourceFiles != null) + { + _logger.LogInformation("{ChangedFilesCount} source files changed", _diffResult.ChangedSourceFiles.Count); + foreach (var changedFile in _diffResult.ChangedSourceFiles) + { + _logger.LogDebug("Changed file {ChangedFile}", changedFile); + } + } + if (_diffResult.ChangedTestFiles != null) + { + _logger.LogInformation("{ChangedFilesCount} test files changed", _diffResult.ChangedTestFiles.Count); + foreach (var changedFile in _diffResult.ChangedTestFiles) + { + _logger.LogDebug("Changed test file {ChangedFile}", changedFile); + } + } + } + } + private IEnumerable SetNotRunMutantsToIgnored(IEnumerable mutants) { foreach (var mutant in mutants.Where(m => m.ResultStatus == MutantStatus.Pending || m.ResultStatus == MutantStatus.NoCoverage)) diff --git a/src/Stryker.Core/Stryker.Core/Mutators/BinaryExpressionMutator.cs b/src/Stryker.Core/Stryker.Core/Mutators/BinaryExpressionMutator.cs index 56c272d711..0ea67da829 100644 --- a/src/Stryker.Core/Stryker.Core/Mutators/BinaryExpressionMutator.cs +++ b/src/Stryker.Core/Stryker.Core/Mutators/BinaryExpressionMutator.cs @@ -19,7 +19,6 @@ public MutationData(Mutator mutator, params SyntaxKind[] kindsToMutate) Mutator = mutator; KindsToMutate = kindsToMutate; } - } private static readonly Dictionary _kindsToMutate = new Dictionary() diff --git a/src/Stryker.Core/Stryker.Core/Options/Inputs/AzureFileStorageSasInput.cs b/src/Stryker.Core/Stryker.Core/Options/Inputs/AzureFileStorageSasInput.cs index d91a8f699b..4e1be15f15 100644 --- a/src/Stryker.Core/Stryker.Core/Options/Inputs/AzureFileStorageSasInput.cs +++ b/src/Stryker.Core/Stryker.Core/Options/Inputs/AzureFileStorageSasInput.cs @@ -11,9 +11,9 @@ public class AzureFileStorageSasInput : Input public override string Default => string.Empty; - public string Validate(BaselineProvider baselineProvider, bool withBaseline) + public string Validate(BaselineProvider baselineProvider, bool baselineEnabled) { - if (withBaseline && baselineProvider == BaselineProvider.AzureFileStorage) + if (baselineEnabled && baselineProvider == BaselineProvider.AzureFileStorage) { if (string.IsNullOrWhiteSpace(SuppliedInput)) { diff --git a/src/Stryker.Core/Stryker.Core/Options/Inputs/AzureFileStorageUrlInput.cs b/src/Stryker.Core/Stryker.Core/Options/Inputs/AzureFileStorageUrlInput.cs index cce0417620..c68cae6216 100644 --- a/src/Stryker.Core/Stryker.Core/Options/Inputs/AzureFileStorageUrlInput.cs +++ b/src/Stryker.Core/Stryker.Core/Options/Inputs/AzureFileStorageUrlInput.cs @@ -13,9 +13,9 @@ public class AzureFileStorageUrlInput : Input public override string Default => string.Empty; - public string Validate(BaselineProvider baselineProvider, bool withBaseline) + public string Validate(BaselineProvider baselineProvider, bool baselineEnabled) { - if (withBaseline && baselineProvider == BaselineProvider.AzureFileStorage) + if (baselineEnabled && baselineProvider == BaselineProvider.AzureFileStorage) { if (SuppliedInput is null) { diff --git a/src/Stryker.Core/Stryker.Core/Options/Inputs/BaselineCreateEnabledInput.cs b/src/Stryker.Core/Stryker.Core/Options/Inputs/BaselineCreateEnabledInput.cs new file mode 100644 index 0000000000..2859535143 --- /dev/null +++ b/src/Stryker.Core/Stryker.Core/Options/Inputs/BaselineCreateEnabledInput.cs @@ -0,0 +1,11 @@ +namespace Stryker.Core.Options.Inputs +{ + public class BaselineRecreateEnabledInput : Input + { + public override bool Default => false; + + protected override string Description => "When enabled a new baseline will be created by doing a full run and storing the mutation results."; + + public bool Validate() => SuppliedInput; + } +} diff --git a/src/Stryker.Core/Stryker.Core/Options/Inputs/BaselineProviderInput.cs b/src/Stryker.Core/Stryker.Core/Options/Inputs/BaselineProviderInput.cs index 7d7171e563..ce4459c77c 100644 --- a/src/Stryker.Core/Stryker.Core/Options/Inputs/BaselineProviderInput.cs +++ b/src/Stryker.Core/Stryker.Core/Options/Inputs/BaselineProviderInput.cs @@ -14,9 +14,9 @@ public class BaselineProviderInput : Input protected override IEnumerable AllowedOptions => EnumToStrings(typeof(BaselineProvider)); - public BaselineProvider Validate(IEnumerable reporters, bool withBaseline) + public BaselineProvider Validate(IEnumerable reporters, bool baselineEnabled) { - if (withBaseline) + if (baselineEnabled) { if (SuppliedInput is not null) { diff --git a/src/Stryker.Core/Stryker.Core/Options/Inputs/BaselineTargetInput.cs b/src/Stryker.Core/Stryker.Core/Options/Inputs/BaselineTargetInput.cs new file mode 100644 index 0000000000..c56af8de77 --- /dev/null +++ b/src/Stryker.Core/Stryker.Core/Options/Inputs/BaselineTargetInput.cs @@ -0,0 +1,24 @@ +using Stryker.Core.Exceptions; + +namespace Stryker.Core.Options.Inputs +{ + public class BaselineTargetInput : Input + { + public override string Default => "master"; + protected override string Description => "The target branch/commit to compare with the current codebase when the baseline feature is enabled."; + + public string Validate(bool sinceEnabled) + { + if (sinceEnabled && SuppliedInput is not null) + { + if (string.IsNullOrWhiteSpace(SuppliedInput)) + { + throw new InputException("The baseline target cannot be empty when the since feature is enabled"); + } + + return SuppliedInput; + } + return Default; + } + } +} diff --git a/src/Stryker.Core/Stryker.Core/Options/Inputs/DashboardApiKeyInput.cs b/src/Stryker.Core/Stryker.Core/Options/Inputs/DashboardApiKeyInput.cs index 8923a47d32..87dec97f34 100644 --- a/src/Stryker.Core/Stryker.Core/Options/Inputs/DashboardApiKeyInput.cs +++ b/src/Stryker.Core/Stryker.Core/Options/Inputs/DashboardApiKeyInput.cs @@ -13,13 +13,13 @@ public class DashboardApiKeyInput : Input public override string Default => null; - public string Validate(bool? withBaseline, BaselineProvider baselineProvider, IEnumerable reporters) + public string Validate(bool? baselineEnabled, BaselineProvider baselineProvider, IEnumerable reporters) { /* the dashboard api key is required if * 1: The dashboard reporter is enabled * 2: The dasboard storage location is chosen for the with-baseline feature AND the with-baseline feature is enabled */ - var dashboardEnabled = (withBaseline.IsNotNullAndTrue() && baselineProvider == BaselineProvider.Dashboard) || reporters.Any(x => x is Reporter.Dashboard or Reporter.RealTimeDashboard); + var dashboardEnabled = (baselineEnabled.IsNotNullAndTrue() && baselineProvider == BaselineProvider.Dashboard) || reporters.Any(x => x is Reporter.Dashboard or Reporter.RealTimeDashboard); if (!dashboardEnabled) { return Default; diff --git a/src/Stryker.Core/Stryker.Core/Options/Inputs/FallbackVersionInput.cs b/src/Stryker.Core/Stryker.Core/Options/Inputs/FallbackVersionInput.cs index f4710a2519..56671e9fca 100644 --- a/src/Stryker.Core/Stryker.Core/Options/Inputs/FallbackVersionInput.cs +++ b/src/Stryker.Core/Stryker.Core/Options/Inputs/FallbackVersionInput.cs @@ -11,9 +11,9 @@ When you don't specify a fallback version the since target will be used as fallb public override string Default => new SinceTargetInput().Default; - public string Validate(bool withBaseline, string projectVersion, string sinceTarget) + public string Validate(bool baselineEnabled, string sinceTarget) { - if (withBaseline) + if (baselineEnabled) { if(SuppliedInput is null) { diff --git a/src/Stryker.Core/Stryker.Core/Options/Inputs/OpenReportEnabledInput.cs b/src/Stryker.Core/Stryker.Core/Options/Inputs/OpenReportEnabledInput.cs index 504ae30baa..ee1a1fe008 100644 --- a/src/Stryker.Core/Stryker.Core/Options/Inputs/OpenReportEnabledInput.cs +++ b/src/Stryker.Core/Stryker.Core/Options/Inputs/OpenReportEnabledInput.cs @@ -4,7 +4,7 @@ public class OpenReportEnabledInput : Input { public override bool Default => false; - protected override string Description => ""; + protected override string Description => "When enabled the report will open automatically after stryker has generated the report."; public bool Validate() => SuppliedInput; } diff --git a/src/Stryker.Core/Stryker.Core/Options/Inputs/ProjectVersionInput.cs b/src/Stryker.Core/Stryker.Core/Options/Inputs/ProjectVersionInput.cs index 166ff79369..f75b0bd829 100644 --- a/src/Stryker.Core/Stryker.Core/Options/Inputs/ProjectVersionInput.cs +++ b/src/Stryker.Core/Stryker.Core/Options/Inputs/ProjectVersionInput.cs @@ -11,13 +11,13 @@ public class ProjectVersionInput : Input protected override string Description => "Project version used in dashboard reporter and baseline feature."; - public string Validate(IEnumerable reporters, bool withBaseline) + public string Validate(IEnumerable reporters, bool baselineEnabled) { - if (reporters.Contains(Reporter.Dashboard) || reporters.Contains(Reporter.RealTimeDashboard) || withBaseline) + if (reporters.Contains(Reporter.Dashboard) || reporters.Contains(Reporter.RealTimeDashboard) || baselineEnabled) { - if (withBaseline && string.IsNullOrWhiteSpace(SuppliedInput)) + if (baselineEnabled && string.IsNullOrWhiteSpace(SuppliedInput)) { - throw new InputException("Project version cannot be empty when baseline is enabled"); + throw new InputException("Project version cannot be empty when baseline is enabled."); } return SuppliedInput ?? Default; } diff --git a/src/Stryker.Core/Stryker.Core/Options/Inputs/ReportersInput.cs b/src/Stryker.Core/Stryker.Core/Options/Inputs/ReportersInput.cs index ab5cfcf548..3ebcf9bf06 100644 --- a/src/Stryker.Core/Stryker.Core/Options/Inputs/ReportersInput.cs +++ b/src/Stryker.Core/Stryker.Core/Options/Inputs/ReportersInput.cs @@ -13,7 +13,7 @@ public class ReportersInput : Input> protected override string Description => "Reporters inform about various stages in the mutation testrun."; protected override IEnumerable AllowedOptions => EnumToStrings(typeof(Reporter)); - public IEnumerable Validate(bool withBaseline) + public IEnumerable Validate(bool baselineEnabled) { HashSet reporters; if (SuppliedInput is not null) @@ -27,7 +27,7 @@ public IEnumerable Validate(bool withBaseline) reporters = new HashSet { Reporter.Progress, Reporter.Html }; } - if(withBaseline) + if(baselineEnabled) { reporters.Add(Reporter.Baseline); } diff --git a/src/Stryker.Core/Stryker.Core/Options/Inputs/SinceInput.cs b/src/Stryker.Core/Stryker.Core/Options/Inputs/SinceInput.cs index b471bd828f..2f02e2c66f 100644 --- a/src/Stryker.Core/Stryker.Core/Options/Inputs/SinceInput.cs +++ b/src/Stryker.Core/Stryker.Core/Options/Inputs/SinceInput.cs @@ -8,9 +8,9 @@ public class SinceInput : Input protected override string Description => "Enables diff compare. Only test changed files."; - public bool Validate(bool? withBaseline) + public bool Validate(bool? baselineEnabled) { - if (withBaseline.IsNotNullAndTrue()) + if (baselineEnabled.IsNotNullAndTrue()) { if (SuppliedInput.HasValue && SuppliedInput.Value) { diff --git a/src/Stryker.Core/Stryker.Core/Options/Inputs/WithBaselineInput.cs b/src/Stryker.Core/Stryker.Core/Options/Inputs/WithBaselineInput.cs index 215c1a0148..6f7552e81a 100644 --- a/src/Stryker.Core/Stryker.Core/Options/Inputs/WithBaselineInput.cs +++ b/src/Stryker.Core/Stryker.Core/Options/Inputs/WithBaselineInput.cs @@ -1,12 +1,12 @@ namespace Stryker.Core.Options.Inputs { - public class WithBaselineInput : Input + public class BaselineEnabledInput : Input { public override bool? Default => false; protected override string Description => "EXPERIMENTAL: Use results stored in stryker dashboard to only test new mutants."; - public WithBaselineInput() { } + public BaselineEnabledInput() { } public bool Validate() { diff --git a/src/Stryker.Core/Stryker.Core/Options/StrykerInputs.cs b/src/Stryker.Core/Stryker.Core/Options/StrykerInputs.cs index 004e999511..2a7a843d77 100644 --- a/src/Stryker.Core/Stryker.Core/Options/StrykerInputs.cs +++ b/src/Stryker.Core/Stryker.Core/Options/StrykerInputs.cs @@ -9,6 +9,7 @@ public interface IStrykerInputs AdditionalTimeoutInput AdditionalTimeoutInput { get; init; } AzureFileStorageSasInput AzureFileStorageSasInput { get; init; } AzureFileStorageUrlInput AzureFileStorageUrlInput { get; init; } + BaselineRecreateEnabledInput BaselineRecreateEnabledInput { get; init; } BaselineProviderInput BaselineProviderInput { get; init; } BasePathInput BasePathInput { get; init; } ConcurrencyInput ConcurrencyInput { get; init; } @@ -45,10 +46,11 @@ public interface IStrykerInputs ThresholdHighInput ThresholdHighInput { get; init; } ThresholdLowInput ThresholdLowInput { get; init; } VerbosityInput VerbosityInput { get; init; } - WithBaselineInput WithBaselineInput { get; init; } + BaselineEnabledInput BaselineEnabledInput { get; init; } OpenReportInput OpenReportInput { get; init; } OpenReportEnabledInput OpenReportEnabledInput { get; init; } BreakOnInitialTestFailureInput BreakOnInitialTestFailureInput { get; init; } + BaselineTargetInput BaselineTargetInput { get; init; } StrykerOptions ValidateAll(); } @@ -82,8 +84,9 @@ public StrykerInputs(IFileSystem fileSystem = null) public SourceProjectNameInput SourceProjectNameInput { get; init; } = new(); public TestProjectsInput TestProjectsInput { get; init; } = new(); public TestCaseFilterInput TestCaseFilterInput { get; init; } = new(); - public WithBaselineInput WithBaselineInput { get; init; } = new(); public ReportersInput ReportersInput { get; init; } = new(); + public BaselineRecreateEnabledInput BaselineRecreateEnabledInput { get; init; } = new(); + public BaselineEnabledInput BaselineEnabledInput { get; init; } = new(); public BaselineProviderInput BaselineProviderInput { get; init; } = new(); public AzureFileStorageUrlInput AzureFileStorageUrlInput { get; init; } = new(); public AzureFileStorageSasInput AzureFileStorageSasInput { get; init; } = new(); @@ -92,6 +95,7 @@ public StrykerInputs(IFileSystem fileSystem = null) public ProjectNameInput ProjectNameInput { get; init; } = new(); public SinceInput SinceInput { get; init; } = new(); public SinceTargetInput SinceTargetInput { get; init; } = new(); + public BaselineTargetInput BaselineTargetInput { get; init; } = new(); public DiffIgnoreChangesInput DiffIgnoreChangesInput { get; init; } = new(); public FallbackVersionInput FallbackVersionInput { get; init; } = new(); public ProjectVersionInput ProjectVersionInput { get; init; } = new(); @@ -112,12 +116,12 @@ public StrykerOptions ValidateAll() var basePath = BasePathInput.Validate(_fileSystem); var outputPath = OutputPathInput.Validate(_fileSystem); var reportFileNameInput = ReportFileNameInput.Validate(); - var withBaseline = WithBaselineInput.Validate(); - var reporters = ReportersInput.Validate(withBaseline); - var baselineProvider = BaselineProviderInput.Validate(reporters, withBaseline); - var sinceEnabled = SinceInput.Validate(WithBaselineInput.SuppliedInput); + var baselineEnabled = BaselineEnabledInput.Validate(); + var baselineRecreateEnabled = BaselineRecreateEnabledInput.Validate(); + var reporters = ReportersInput.Validate(baselineEnabled); + var baselineProvider = BaselineProviderInput.Validate(reporters, baselineEnabled); + var sinceEnabled = SinceInput.Validate(BaselineEnabledInput.SuppliedInput); var sinceTarget = SinceTargetInput.Validate(sinceEnabled); - var projectVersion = ProjectVersionInput.Validate(reporters, withBaseline); _strykerOptionsCache ??= new StrykerOptions() { @@ -154,16 +158,17 @@ public StrykerOptions ValidateAll() TestProjects = TestProjectsInput.Validate(), TestCaseFilter = TestCaseFilterInput.Validate(), DashboardUrl = DashboardUrlInput.Validate(), - DashboardApiKey = DashboardApiKeyInput.Validate(withBaseline, baselineProvider, reporters), + DashboardApiKey = DashboardApiKeyInput.Validate(baselineEnabled, baselineProvider, reporters), ProjectName = ProjectNameInput.Validate(), ModuleName = ModuleNameInput.Validate(), - ProjectVersion = ProjectVersionInput.Validate(reporters, withBaseline), + ProjectVersion = ProjectVersionInput.Validate(reporters, baselineEnabled), DiffIgnoreChanges = DiffIgnoreChangesInput.Validate(), - AzureFileStorageSas = AzureFileStorageSasInput.Validate(baselineProvider, withBaseline), - AzureFileStorageUrl = AzureFileStorageUrlInput.Validate(baselineProvider, withBaseline), - WithBaseline = withBaseline, + AzureFileStorageSas = AzureFileStorageSasInput.Validate(baselineProvider, baselineEnabled), + AzureFileStorageUrl = AzureFileStorageUrlInput.Validate(baselineProvider, baselineEnabled), + RecreateBaseline = baselineRecreateEnabled, + BaselineEnabled = baselineEnabled, BaselineProvider = baselineProvider, - FallbackVersion = FallbackVersionInput.Validate(withBaseline, projectVersion, sinceTarget), + FallbackVersion = FallbackVersionInput.Validate(baselineEnabled, sinceTarget), Since = sinceEnabled, SinceTarget = sinceTarget, ReportTypeToOpen = OpenReportInput.Validate(OpenReportEnabledInput.Validate()), diff --git a/src/Stryker.Core/Stryker.Core/Options/StrykerOptions.cs b/src/Stryker.Core/Stryker.Core/Options/StrykerOptions.cs index 1879f91c1b..548829c51b 100644 --- a/src/Stryker.Core/Stryker.Core/Options/StrykerOptions.cs +++ b/src/Stryker.Core/Stryker.Core/Options/StrykerOptions.cs @@ -121,10 +121,15 @@ public class StrykerOptions /// public IEnumerable Reporters { get; init; } = []; + /// + /// When true, a new baseline should be created. + /// + public bool RecreateBaseline { get; init; } + /// /// When true, the baseline feature should be enabled. /// - public bool WithBaseline { get; init; } + public bool BaselineEnabled { get; init; } /// /// When the baseline feature is enabled, this selects the source of the baseline. diff --git a/src/Stryker.Core/Stryker.Core/StrykerRunner.cs b/src/Stryker.Core/Stryker.Core/StrykerRunner.cs index d025014c73..36f2ad7e7c 100644 --- a/src/Stryker.Core/Stryker.Core/StrykerRunner.cs +++ b/src/Stryker.Core/Stryker.Core/StrykerRunner.cs @@ -1,6 +1,4 @@ -#if !DEBUG using System; -#endif using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -129,7 +127,6 @@ public StrykerRunResult RunMutationTest(IStrykerInputs inputs, ILoggerFactory lo reporters.OnAllMutantsTested(rootComponent, combinedTestProjectsInfo); - return new StrykerRunResult(options, rootComponent.GetMutationScore()); } #if !DEBUG @@ -139,7 +136,6 @@ public StrykerRunResult RunMutationTest(IStrykerInputs inputs, ILoggerFactory lo _logger.LogError(ex, "An error occurred during the mutation test run "); throw; } - #endif finally {