From 194e995490ad4d6e4dcade07a6102dc12c16f92e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1sp=C3=A1r=20Nagy?= Date: Fri, 12 Jul 2024 16:47:57 +0200 Subject: [PATCH] remove unused SpecRun support from TestProjectGenerator (#206) * remove unused SpecRun support from TestProjectGenerator * remove further specrun stuff --- Tests/Reqnroll.Specs/Support/Hooks.cs | 1 - Tests/Reqnroll.SystemTests/SystemTestBase.cs | 1 - .../GenerateSolutionParams.cs | 2 -- .../Program.cs | 26 +++++++------------ .../AppConfigGeneratorTests.cs | 6 ++--- .../JsonConfigGeneratorTests.cs | 6 ++--- .../CurrentVersionDriver.cs | 2 -- .../Driver/ConfigurationFileDriver.cs | 4 --- .../Driver/SolutionDriver.cs | 5 ---- .../Extensions/UnitTestProviderExtensions.cs | 4 --- .../ProjectBuilder.cs | 4 --- .../TRXParser.cs | 16 ------------ .../UnitTestProvider.cs | 20 +++++--------- .../VSTestExecutionDriver.cs | 8 ------ 14 files changed, 23 insertions(+), 82 deletions(-) diff --git a/Tests/Reqnroll.Specs/Support/Hooks.cs b/Tests/Reqnroll.Specs/Support/Hooks.cs index a20729e6b..da6611b6e 100644 --- a/Tests/Reqnroll.Specs/Support/Hooks.cs +++ b/Tests/Reqnroll.Specs/Support/Hooks.cs @@ -33,7 +33,6 @@ public void BeforeScenario() ConfigurationFormat = ConfigurationFormat.Json }); - _currentVersionDriver.NuGetVersion = NuGetPackageVersion.Version; _currentVersionDriver.ReqnrollNuGetVersion = NuGetPackageVersion.Version; _scenarioContext.ScenarioContainer.RegisterTypeAs(); diff --git a/Tests/Reqnroll.SystemTests/SystemTestBase.cs b/Tests/Reqnroll.SystemTests/SystemTestBase.cs index e0b8d9013..d1c0d49be 100644 --- a/Tests/Reqnroll.SystemTests/SystemTestBase.cs +++ b/Tests/Reqnroll.SystemTests/SystemTestBase.cs @@ -72,7 +72,6 @@ protected virtual void TestInitialize() _testRunConfiguration.UnitTestProvider = UnitTestProvider.MSTest; _currentVersionDriver = _testContainer.GetService(); - _currentVersionDriver.NuGetVersion = NuGetPackageVersion.Version; _currentVersionDriver.ReqnrollNuGetVersion = NuGetPackageVersion.Version; _folderCleaner = _testContainer.GetService(); diff --git a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Cli/GenerateSolutionParams.cs b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Cli/GenerateSolutionParams.cs index c7de882de..f22757b56 100644 --- a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Cli/GenerateSolutionParams.cs +++ b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Cli/GenerateSolutionParams.cs @@ -23,8 +23,6 @@ public class GenerateSolutionParams public ConfigurationFormat ConfigurationFormat { get; set; } - public string SpecrunNuGetVersion { get; set; } - public int FeatureCount { get; set; } } } diff --git a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Cli/Program.cs b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Cli/Program.cs index caed74ef7..d5592bac4 100644 --- a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Cli/Program.cs +++ b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Cli/Program.cs @@ -5,21 +5,19 @@ using System.CommandLine.Invocation; using System.IO; using System.Text.RegularExpressions; -using Reqnroll.TestProjectGenerator; using Reqnroll.TestProjectGenerator.Conventions; using Reqnroll.TestProjectGenerator.Data; using Reqnroll.TestProjectGenerator.Driver; namespace Reqnroll.TestProjectGenerator.Cli { - partial class Program + class Program { private const string DefaultReqnrollNuGetVersion = "3.4.3"; - private const UnitTestProvider DefaultUnitTestProvider = UnitTestProvider.SpecRun; + private const UnitTestProvider DefaultUnitTestProvider = UnitTestProvider.MSTest; private const TargetFramework DefaultTargetFramework = TargetFramework.Netcoreapp31; private const ProjectFormat DefaultProjectFormat = ProjectFormat.New; private const ConfigurationFormat DefaultConfigurationFormat = ConfigurationFormat.Json; - private const string DefaultSpecRunNuGetVersion = "3.4.19"; static int Main(string[] args) { @@ -55,10 +53,6 @@ static int Main(string[] args) "--configuration-format", () => DefaultConfigurationFormat, $"The format of the generated Reqnroll configuration file. Default: '{DefaultConfigurationFormat}'."), - new Option( - "--specrun-nuget-version", - () => DefaultSpecRunNuGetVersion, - $"The SpecRun NuGet version referenced in the generated project (if SpecRun is used as unit test provider). Default: '{DefaultSpecRunNuGetVersion}'."), new Option( "--feature-count", () => 1, @@ -73,13 +67,13 @@ static int Main(string[] args) { var services = ConfigureServices(); - services.AddSingleton(s => new SolutionConfiguration + services.AddSingleton(_ => new SolutionConfiguration { OutDir = generateSolutionParams.OutDir, SolutionName = generateSolutionParams.SlnName }); - services.AddSingleton(s => new TestRunConfiguration + services.AddSingleton(_ => new TestRunConfiguration { ProgrammingLanguage = ProgrammingLanguage.CSharp, UnitTestProvider = generateSolutionParams.UnitTestProvider, @@ -88,19 +82,19 @@ static int Main(string[] args) TargetFramework = generateSolutionParams.TargetFramework, }); - Func getRunnerReqnrollVersion = (string reqnrollNuGetVersion) => + Version GetReqnrollVersion(string reqnrollNuGetVersion) { var m = new Regex("^(\\d+)\\.(\\d+)").Match(reqnrollNuGetVersion); return new Version(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), 0); - }; - services.AddSingleton(s => new CurrentVersionDriver + } + + services.AddSingleton(_ => new CurrentVersionDriver { ReqnrollNuGetVersion = generateSolutionParams.ReqnrollNuGetVersion.ToString(), - ReqnrollVersion = getRunnerReqnrollVersion(generateSolutionParams.ReqnrollNuGetVersion), - NuGetVersion = generateSolutionParams.SpecrunNuGetVersion.ToString() + ReqnrollVersion = GetReqnrollVersion(generateSolutionParams.ReqnrollNuGetVersion), }); - services.AddSingleton(s => generateSolutionParams); + services.AddSingleton(_ => generateSolutionParams); var serviceProvider = services.BuildServiceProvider(); diff --git a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Tests/AppConfigGeneratorTests.cs b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Tests/AppConfigGeneratorTests.cs index 730e35230..3f8253937 100644 --- a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Tests/AppConfigGeneratorTests.cs +++ b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Tests/AppConfigGeneratorTests.cs @@ -18,7 +18,7 @@ public AppConfigGeneratorTests() [Fact] public void FileNameIsAppConfig() { - var configuration = new Configuration {UnitTestProvider = Reqnroll.TestProjectGenerator.UnitTestProvider.SpecRun}; + var configuration = new Configuration(); var projectFile = _appConfigGenerator.Generate(configuration); projectFile.Path.Should().Be("app.config"); } @@ -26,7 +26,7 @@ public void FileNameIsAppConfig() [Fact] public void BuildActionIsNone() { - var configuration = new Configuration { UnitTestProvider = Reqnroll.TestProjectGenerator.UnitTestProvider.SpecRun }; + var configuration = new Configuration(); var projectFile = _appConfigGenerator.Generate(configuration); projectFile.BuildAction.Should().Be("None"); } @@ -36,7 +36,7 @@ public void BuildActionIsNone() [Fact] public void SingleAdditionalStepAssembly() { - var configuration = new Configuration { UnitTestProvider = Reqnroll.TestProjectGenerator.UnitTestProvider.SpecRun }; + var configuration = new Configuration(); configuration.BindingAssemblies.Add(new BindingAssembly("AdditionalStepAssembly")); var projectFile = _appConfigGenerator.Generate(configuration); diff --git a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Tests/JsonConfigGeneratorTests.cs b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Tests/JsonConfigGeneratorTests.cs index 57d2d6239..5152e42b8 100644 --- a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Tests/JsonConfigGeneratorTests.cs +++ b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Tests/JsonConfigGeneratorTests.cs @@ -18,7 +18,7 @@ public JsonConfigGeneratorTests() [Fact] public void FileNameIsAppConfig() { - var configuration = new Configuration { UnitTestProvider = Reqnroll.TestProjectGenerator.UnitTestProvider.SpecRun }; + var configuration = new Configuration(); var projectFile = _jsonConfigGenerator.Generate(configuration); projectFile.Path.Should().Be("reqnroll.json"); } @@ -26,7 +26,7 @@ public void FileNameIsAppConfig() [Fact] public void BuildActionIsNone() { - var configuration = new Configuration { UnitTestProvider = Reqnroll.TestProjectGenerator.UnitTestProvider.SpecRun }; + var configuration = new Configuration(); var projectFile = _jsonConfigGenerator.Generate(configuration); projectFile.BuildAction.Should().Be("None"); } @@ -34,7 +34,7 @@ public void BuildActionIsNone() [Fact] public void SingleAdditionalStepAssembly() { - var configuration = new Configuration { UnitTestProvider = Reqnroll.TestProjectGenerator.UnitTestProvider.SpecRun }; + var configuration = new Configuration(); configuration.BindingAssemblies.Add(new BindingAssembly("AdditionalStepAssembly")); var projectFile = _jsonConfigGenerator.Generate(configuration); diff --git a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/CurrentVersionDriver.cs b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/CurrentVersionDriver.cs index 78c95c776..7f9173a21 100644 --- a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/CurrentVersionDriver.cs +++ b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/CurrentVersionDriver.cs @@ -26,8 +26,6 @@ public CurrentVersionDriver() public string ReqnrollNuGetVersion { get; set; } - public string NuGetVersion { get; set; } - public string MajorMinorPatchVersion { get; set; } } } diff --git a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/Driver/ConfigurationFileDriver.cs b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/Driver/ConfigurationFileDriver.cs index 9272f1ccc..90e498d16 100644 --- a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/Driver/ConfigurationFileDriver.cs +++ b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/Driver/ConfigurationFileDriver.cs @@ -81,10 +81,6 @@ private UnitTestProvider GetUnitTestProvider(string providerName) { switch (providerName.ToLower()) { - case "specrun+nunit": return UnitTestProvider.SpecRunWithNUnit; - case "specrun+nunit.2": return UnitTestProvider.SpecRunWithNUnit2; - case "specrun+mstest": return UnitTestProvider.SpecRunWithMsTest; - case "specrun": return UnitTestProvider.SpecRun; case "mstest": return UnitTestProvider.MSTest; case "xunit": return UnitTestProvider.xUnit; case "nunit": return UnitTestProvider.NUnit3; diff --git a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/Driver/SolutionDriver.cs b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/Driver/SolutionDriver.cs index 159a5a31f..57f6efa73 100644 --- a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/Driver/SolutionDriver.cs +++ b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/Driver/SolutionDriver.cs @@ -44,11 +44,6 @@ public SolutionDriver( new("Reqnroll Unstable", "https://www.myget.org/F/reqnroll-unstable/api/v3/index.json") }; - if (testRunConfiguration.UnitTestProvider == UnitTestProvider.SpecRun) - { - NuGetSources.Add(new NuGetSource("Reqnroll CI", "https://www.myget.org/F/reqnroll/api/v3/index.json")); - NuGetSources.Add(new NuGetSource("Reqnroll Unstable", "https://www.myget.org/F/reqnroll-unstable/api/v3/index.json")); - } if (testRunConfiguration.TargetFramework == TargetFramework.Net50 && testRunConfiguration.UnitTestProvider == UnitTestProvider.NUnit3) { //NUnit is not supporting .NET 5 in the latest release (3.12.0), so add the myget feed for the pre-release versions diff --git a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/Extensions/UnitTestProviderExtensions.cs b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/Extensions/UnitTestProviderExtensions.cs index a83717f62..671bd5ca9 100644 --- a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/Extensions/UnitTestProviderExtensions.cs +++ b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/Extensions/UnitTestProviderExtensions.cs @@ -8,14 +8,10 @@ public static string ToName(this UnitTestProvider unitTestProvider) { switch (unitTestProvider) { - case UnitTestProvider.SpecRunWithNUnit: return "SpecRun+NUnit"; - case UnitTestProvider.SpecRunWithNUnit2: return "SpecRun+NUnit.2"; - case UnitTestProvider.SpecRunWithMsTest: return "SpecRun+MsTest"; case UnitTestProvider.MSTest: return "MSTest"; case UnitTestProvider.NUnit2: return "NUnit2"; case UnitTestProvider.NUnit3: return "NUnit"; case UnitTestProvider.xUnit: return "XUnit"; - case UnitTestProvider.SpecRun: return "SpecRun"; default: throw new ArgumentOutOfRangeException(nameof(unitTestProvider), unitTestProvider, "value is not known"); } } diff --git a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/ProjectBuilder.cs b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/ProjectBuilder.cs index d978d2fe3..0578b355a 100644 --- a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/ProjectBuilder.cs +++ b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/ProjectBuilder.cs @@ -263,10 +263,6 @@ private void EnsureProjectExists() switch (Configuration.UnitTestProvider) { - case UnitTestProvider.SpecRun: - case UnitTestProvider.SpecRunWithMsTest: - case UnitTestProvider.SpecRunWithNUnit: - throw new NotSupportedException("Testing with SpecRun is not supported!"); case UnitTestProvider.MSTest: ConfigureMSTest(); break; diff --git a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/TRXParser.cs b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/TRXParser.cs index 44a7648f1..2526562a2 100644 --- a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/TRXParser.cs +++ b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/TRXParser.cs @@ -94,26 +94,10 @@ private TestExecutionResult CalculateUnitTestProviderSpecificTestExecutionResult case UnitTestProvider.xUnit: return CalculateXUnitTestExecutionResult(testExecutionResult, trx); case UnitTestProvider.MSTest: return CalculateMsTestTestExecutionResult(testExecutionResult); case UnitTestProvider.NUnit3: return CalculateNUnitTestExecutionResult(testExecutionResult); - case UnitTestProvider.SpecRun: return CalculateSpecRunTestExecutionResult(testExecutionResult); default: throw new NotSupportedException($"The specified unit test provider is not supported: {testRunConfiguration.UnitTestProvider}"); } } - private TestExecutionResult CalculateSpecRunTestExecutionResult(TestExecutionResult testExecutionResult) - { - bool FilterIgnored(TestResult testResult) => testResult.StdOut.Contains("-> Ignored"); - - bool FilterPending(TestResult testResult) => testResult.StdOut.Contains("TechTalk.SpecRun.PendingTestException") - || testResult.StdOut.Contains("No matching step definition found for the step."); - - var testResultsWithOutput = testExecutionResult.TestResults.Where(tr => !(tr?.StdOut is null)).ToArray(); - - testExecutionResult.Ignored = testResultsWithOutput.Where(FilterIgnored).Count(); - testExecutionResult.Pending = testResultsWithOutput.Where(FilterPending).Count(); - - return testExecutionResult; - } - private TestExecutionResult CalculateNUnitTestExecutionResult(TestExecutionResult testExecutionResult) { testExecutionResult.Ignored = GetNUnitIgnoredCount(testExecutionResult); diff --git a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/UnitTestProvider.cs b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/UnitTestProvider.cs index 113e86e5f..3211585c4 100644 --- a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/UnitTestProvider.cs +++ b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/UnitTestProvider.cs @@ -1,15 +1,9 @@ -namespace Reqnroll.TestProjectGenerator +namespace Reqnroll.TestProjectGenerator; + +public enum UnitTestProvider { - public enum UnitTestProvider - { - SpecRun, - SpecRunWithNUnit, - SpecRunWithNUnit2, - SpecRunWithMsTest, - MSTest, - xUnit, - NUnit3, - NUnit2 - - } + MSTest, + xUnit, + NUnit3, + NUnit2 } \ No newline at end of file diff --git a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/VSTestExecutionDriver.cs b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/VSTestExecutionDriver.cs index c1edcc62b..e541189a6 100644 --- a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/VSTestExecutionDriver.cs +++ b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator/VSTestExecutionDriver.cs @@ -199,14 +199,6 @@ public string GenerateVerbosityParameter(string verbosity) public string GenerateAdditionalPackagesFoldersParameters() { - if (_testRunConfiguration.UnitTestProvider != UnitTestProvider.SpecRun) - { - if (_testRunConfiguration.ProjectFormat == ProjectFormat.Old) - { - return $" --test-adapter-path \"{_testProjectFolders.PathToNuGetPackages}\""; - } - } - return null; } }