diff --git a/Tms.Adapter.Core/Tms.Adapter.Core.csproj b/Tms.Adapter.Core/Tms.Adapter.Core.csproj index 25d01a1..3031048 100644 --- a/Tms.Adapter.Core/Tms.Adapter.Core.csproj +++ b/Tms.Adapter.Core/Tms.Adapter.Core.csproj @@ -1,7 +1,7 @@  - 1.6.4 + 1.6.5 netstandard2.1 enable true diff --git a/Tms.Adapter.SpecFlowPlugin/Tms.Adapter.SpecFlowPlugin.csproj b/Tms.Adapter.SpecFlowPlugin/Tms.Adapter.SpecFlowPlugin.csproj index 70cd648..6e74b04 100644 --- a/Tms.Adapter.SpecFlowPlugin/Tms.Adapter.SpecFlowPlugin.csproj +++ b/Tms.Adapter.SpecFlowPlugin/Tms.Adapter.SpecFlowPlugin.csproj @@ -1,7 +1,7 @@  - 1.6.4 + 1.6.5 netstandard2.1 enable true diff --git a/Tms.Adapter.XUnit/Tms.Adapter.XUnit.csproj b/Tms.Adapter.XUnit/Tms.Adapter.XUnit.csproj index b3eaed4..02fa370 100644 --- a/Tms.Adapter.XUnit/Tms.Adapter.XUnit.csproj +++ b/Tms.Adapter.XUnit/Tms.Adapter.XUnit.csproj @@ -1,7 +1,7 @@  - 1.6.4 + 1.6.5 netstandard2.1 enable true diff --git a/Tms.Adapter/Tms.Adapter.csproj b/Tms.Adapter/Tms.Adapter.csproj index 4c95fce..3ed921b 100644 --- a/Tms.Adapter/Tms.Adapter.csproj +++ b/Tms.Adapter/Tms.Adapter.csproj @@ -1,7 +1,7 @@  - 1.6.4 + 1.6.5 netstandard2.1 enable true diff --git a/TmsRunner/App.cs b/TmsRunner/App.cs index cb67a31..bdb914d 100644 --- a/TmsRunner/App.cs +++ b/TmsRunner/App.cs @@ -48,7 +48,7 @@ public async Task RunAsync() if (!string.IsNullOrEmpty(adapterConfig.TmsLabelsOfTestsToRun)) { - testCases = FilterService.FilterTestCasesByLabels(adapterConfig, testCases); + testCases = filterService.FilterTestCasesByLabels(adapterConfig, testCases); } break; diff --git a/TmsRunner/Services/FilterService.cs b/TmsRunner/Services/FilterService.cs index bec19db..9be0e9a 100644 --- a/TmsRunner/Services/FilterService.cs +++ b/TmsRunner/Services/FilterService.cs @@ -66,21 +66,25 @@ private string GetExternalId(MethodInfo testMethod, TestCase testCase) return (testMethod.DeclaringType!.FullName + "." + testMethod.Name).ComputeHash(); } - public static List FilterTestCasesByLabels(AdapterConfig config, IReadOnlyCollection testCases) + public List FilterTestCasesByLabels(AdapterConfig config, IReadOnlyCollection testCases) { var labelsToRun = config.TmsLabelsOfTestsToRun?.Split(',').Select(x => x.Trim()).ToList(); - var testCasesName = testCases.Select(t => t.FullyQualifiedName); var testCasesToRun = new List(); var assembly = Assembly.LoadFrom(config.TestAssemblyPath ?? string.Empty); - var testMethods = new List( - assembly.GetExportedTypes() - .SelectMany(type => type.GetMethods()) - .Where(m => testCasesName.Contains(m.DeclaringType!.FullName + "." + m.Name)) - ); + var allTestMethods = new List(assembly.GetExportedTypes().SelectMany(type => type.GetMethods())); - foreach (var testMethod in testMethods) + foreach (var testCase in testCases) { - var fullName = testMethod.DeclaringType?.FullName + "." + testMethod.Name; + var testMethod = allTestMethods.FirstOrDefault( + m => (m.DeclaringType!.FullName + "." + m.Name).Contains(ParametersRegex.Replace(testCase.FullyQualifiedName, string.Empty)) + ); + + if (testMethod == null) + { + logger.LogError("TestMethod {@FullyQualifiedName} not found", testCase.FullyQualifiedName); + continue; + } + var customAttributes = testMethod.GetCustomAttributes(false); foreach (var attribute in customAttributes) @@ -89,8 +93,6 @@ public static List FilterTestCasesByLabels(AdapterConfig config, IRead { if (labelsAttr.Value?.Any(x => labelsToRun?.Contains(x) ?? false) ?? false) { - var testCase = testCases.FirstOrDefault(x => x.FullyQualifiedName == fullName); - if (testCase != null) { testCasesToRun.Add(testCase); diff --git a/TmsRunner/TmsRunner.csproj b/TmsRunner/TmsRunner.csproj index 1f4db6e..eb620e8 100644 --- a/TmsRunner/TmsRunner.csproj +++ b/TmsRunner/TmsRunner.csproj @@ -1,7 +1,7 @@  - 1.6.4 + 1.6.5 Exe enable enable diff --git a/TmsRunnerTests/Services/FilterServiceTests.cs b/TmsRunnerTests/Services/FilterServiceTests.cs index 90ef052..87cd9ec 100644 --- a/TmsRunnerTests/Services/FilterServiceTests.cs +++ b/TmsRunnerTests/Services/FilterServiceTests.cs @@ -33,14 +33,15 @@ public void FilterTestCases() public void FilterTestCasesByLabels() { // Arrange + var filterService = new FilterService(_logger, _replacer); var config = new AdapterConfig { TestAssemblyPath = typeof(FilterServiceTests).Assembly.Location }; - var testcases = new[] { new TestCase() }; + var testcases = new[] { new TestCase { FullyQualifiedName = "test" } }; // Act - var actual = FilterService.FilterTestCasesByLabels(config, testcases); + var actual = filterService.FilterTestCasesByLabels(config, testcases); // Assert Assert.AreEqual(0, actual.Count);