diff --git a/tests/BenchmarkDotNet.IntegrationTests.FSharp/Program.fs b/tests/BenchmarkDotNet.IntegrationTests.FSharp/Program.fs index b90d780ce5..e8192e4c62 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.FSharp/Program.fs +++ b/tests/BenchmarkDotNet.IntegrationTests.FSharp/Program.fs @@ -28,13 +28,9 @@ type Db() = type TestEnum = | A = 0 | B = 1 | C = 2 type EnumParamsTest() = - let mutable collectedParams = HashSet() - - [] + [] member val EnumParamValue = TestEnum.A with get, set [] member this.Benchmark() = - if not <| collectedParams.Contains(this.EnumParamValue) then - printfn "// ### New Parameter %A ###" this.EnumParamValue - collectedParams.Add(this.EnumParamValue) |> ignore \ No newline at end of file + if not (this.EnumParamValue = TestEnum.B) then failwith "Invalid Params value assigned" diff --git a/tests/BenchmarkDotNet.IntegrationTests/AllSetupAndCleanupTest.cs b/tests/BenchmarkDotNet.IntegrationTests/AllSetupAndCleanupTest.cs index 5bb5e225a2..6975a01401 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/AllSetupAndCleanupTest.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/AllSetupAndCleanupTest.cs @@ -52,9 +52,8 @@ private static string[] GetActualLogLines(Summary summary) [Fact] public void AllSetupAndCleanupMethodRunsTest() { - var logger = new OutputLogger(Output); var miniJob = Job.Default.WithStrategy(RunStrategy.Monitoring).WithWarmupCount(2).WithIterationCount(3).WithInvocationCount(1).WithUnrollFactor(1).WithId("MiniJob"); - var config = CreateSimpleConfig(logger, miniJob); + var config = CreateSimpleConfig(job: miniJob); var summary = CanExecute(config); @@ -88,9 +87,8 @@ public class AllSetupAndCleanupAttributeBenchmarks [Fact] public void AllSetupAndCleanupMethodRunsAsyncTest() { - var logger = new OutputLogger(Output); var miniJob = Job.Default.WithStrategy(RunStrategy.Monitoring).WithWarmupCount(2).WithIterationCount(3).WithInvocationCount(1).WithUnrollFactor(1).WithId("MiniJob"); - var config = CreateSimpleConfig(logger, miniJob); + var config = CreateSimpleConfig(job: miniJob); var summary = CanExecute(config); @@ -124,9 +122,8 @@ public class AllSetupAndCleanupAttributeBenchmarksAsync [Fact] public void AllSetupAndCleanupMethodRunsAsyncTaskSetupTest() { - var logger = new OutputLogger(Output); var miniJob = Job.Default.WithStrategy(RunStrategy.Monitoring).WithWarmupCount(2).WithIterationCount(3).WithInvocationCount(1).WithUnrollFactor(1).WithId("MiniJob"); - var config = CreateSimpleConfig(logger, miniJob); + var config = CreateSimpleConfig(job: miniJob); var summary = CanExecute(config); @@ -160,9 +157,8 @@ public class AllSetupAndCleanupAttributeBenchmarksAsyncTaskSetup [Fact] public void AllSetupAndCleanupMethodRunsAsyncGenericTaskSetupTest() { - var logger = new OutputLogger(Output); var miniJob = Job.Default.WithStrategy(RunStrategy.Monitoring).WithWarmupCount(2).WithIterationCount(3).WithInvocationCount(1).WithUnrollFactor(1).WithId("MiniJob"); - var config = CreateSimpleConfig(logger, miniJob); + var config = CreateSimpleConfig(job: miniJob); var summary = CanExecute(config); @@ -206,9 +202,8 @@ public async Task GlobalCleanup() [Fact] public void AllSetupAndCleanupMethodRunsAsyncValueTaskSetupTest() { - var logger = new OutputLogger(Output); var miniJob = Job.Default.WithStrategy(RunStrategy.Monitoring).WithWarmupCount(2).WithIterationCount(3).WithInvocationCount(1).WithUnrollFactor(1).WithId("MiniJob"); - var config = CreateSimpleConfig(logger, miniJob); + var config = CreateSimpleConfig(job: miniJob); var summary = CanExecute(config); @@ -242,9 +237,8 @@ public class AllSetupAndCleanupAttributeBenchmarksAsyncValueTaskSetup [FactNotGitHubActionsWindows] public void AllSetupAndCleanupMethodRunsAsyncGenericValueTaskSetupTest() { - var logger = new OutputLogger(Output); var miniJob = Job.Default.WithStrategy(RunStrategy.Monitoring).WithWarmupCount(2).WithIterationCount(3).WithInvocationCount(1).WithUnrollFactor(1).WithId("MiniJob"); - var config = CreateSimpleConfig(logger, miniJob); + var config = CreateSimpleConfig(job: miniJob); var summary = CanExecute(config); diff --git a/tests/BenchmarkDotNet.IntegrationTests/FSharpTests.cs b/tests/BenchmarkDotNet.IntegrationTests/FSharpTests.cs index 89bd3e29ca..2b0928e9b4 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/FSharpTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/FSharpTests.cs @@ -1,8 +1,5 @@ -using System; -using Xunit; +using Xunit; using Xunit.Abstractions; - -using BenchmarkDotNet.Tests.Loggers; using static FSharpBenchmarks; namespace BenchmarkDotNet.IntegrationTests @@ -12,15 +9,6 @@ public class FSharpTests : BenchmarkTestExecutor public FSharpTests(ITestOutputHelper output) : base(output) { } [Fact] - public void ParamsSupportFSharpEnums() - { - var logger = new OutputLogger(Output); - var config = CreateSimpleConfig(logger); - - CanExecute(config); - foreach (var param in new[] { TestEnum.A, TestEnum.B }) - Assert.Contains($"// ### New Parameter {param} ###" + Environment.NewLine, logger.GetLog()); - Assert.DoesNotContain($"// ### New Parameter {TestEnum.C} ###" + Environment.NewLine, logger.GetLog()); - } + public void ParamsSupportFSharpEnums() => CanExecute(); } } diff --git a/tests/BenchmarkDotNet.IntegrationTests/PowerManagementApplierTests.cs b/tests/BenchmarkDotNet.IntegrationTests/PowerManagementApplierTests.cs index de129c9ac1..46bc67d655 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/PowerManagementApplierTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/PowerManagementApplierTests.cs @@ -18,8 +18,7 @@ public PowerManagementApplierTests(ITestOutputHelper output) : base(output) { } public void TestSettingAndRevertingBackGuid() { var userPlan = PowerManagementHelper.CurrentPlan; - var logger = new OutputLogger(Output); - var powerManagementApplier = new PowerManagementApplier(logger); + var powerManagementApplier = new PowerManagementApplier(new OutputLogger(Output)); powerManagementApplier.ApplyPerformancePlan(PowerManagementApplier.Map(PowerPlan.HighPerformance)); @@ -34,8 +33,7 @@ public void TestSettingAndRevertingBackGuid() public void TestPowerPlanShouldNotChange() { var userPlan = PowerManagementHelper.CurrentPlan; - var logger = new OutputLogger(Output); - var powerManagementApplier = new PowerManagementApplier(logger); + var powerManagementApplier = new PowerManagementApplier(new OutputLogger(Output)); powerManagementApplier.ApplyPerformancePlan(PowerManagementApplier.Map(PowerPlan.UserPowerPlan)); diff --git a/tests/BenchmarkDotNet.IntegrationTests/PriorityTests.cs b/tests/BenchmarkDotNet.IntegrationTests/PriorityTests.cs index 4976362314..47ba0b4089 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/PriorityTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/PriorityTests.cs @@ -14,8 +14,7 @@ public PriorityTests(ITestOutputHelper output) : base(output) { } [Fact] public void ParamsSupportPropertyWithPublicSetter() { - var logger = new OutputLogger(Output); - var config = CreateSimpleConfig(logger); + var config = CreateSimpleConfig(); var summary = CanExecute(config); var columns = summary.Table.Columns; diff --git a/tests/BenchmarkDotNet.IntegrationTests/ProcessorArchitectureTest.cs b/tests/BenchmarkDotNet.IntegrationTests/ProcessorArchitectureTest.cs index 3726316207..ea942ef8f5 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/ProcessorArchitectureTest.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/ProcessorArchitectureTest.cs @@ -27,11 +27,9 @@ public void SpecifiedProcessorArchitectureMustBeRespected() private void Verify(Platform platform, Type benchmark) { - var logger = new OutputLogger(Output); - var config = ManualConfig.CreateEmpty() .AddJob(Job.Dry.WithPlatform(platform)) - .AddLogger(logger); // make sure we get an output in the TestRunner log + .AddLogger(new OutputLogger(Output)); // make sure we get an output in the TestRunner log // CanExecute ensures that at least one benchmark has executed successfully CanExecute(benchmark, config, fullValidation: true); diff --git a/tests/BenchmarkDotNet.IntegrationTests/RoslynToolchainTest.cs b/tests/BenchmarkDotNet.IntegrationTests/RoslynToolchainTest.cs index 472ba3907a..74fcb3137b 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/RoslynToolchainTest.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/RoslynToolchainTest.cs @@ -31,9 +31,8 @@ public void CanExecuteWithNonDefaultUiCulture(string culture) CultureInfo.CurrentCulture = overrideCulture; CultureInfo.CurrentUICulture = overrideCulture; - var logger = new OutputLogger(Output); var miniJob = Job.Dry.WithToolchain(RoslynToolchain.Instance); - var config = CreateSimpleConfig(logger, miniJob); + var config = CreateSimpleConfig(job: miniJob); CanExecute(config); } diff --git a/tests/BenchmarkDotNet.IntegrationTests/SetupAndCleanupTests.cs b/tests/BenchmarkDotNet.IntegrationTests/SetupAndCleanupTests.cs index 82afc50466..a915c2d60b 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/SetupAndCleanupTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/SetupAndCleanupTests.cs @@ -78,9 +78,8 @@ public SetupAndCleanupTests(ITestOutputHelper output) : base(output) { } [Fact] public void AllSetupAndCleanupMethodRunsForSpecificBenchmark() { - var logger = new OutputLogger(Output); var miniJob = Job.Default.WithStrategy(RunStrategy.Monitoring).WithWarmupCount(2).WithIterationCount(3).WithInvocationCount(1).WithUnrollFactor(1).WithId("MiniJob"); - var config = CreateSimpleConfig(logger, miniJob); + var config = CreateSimpleConfig(job: miniJob); var summary = CanExecute(config); var standardOutput = GetCombinedStandardOutput(summary);