@@ -276,7 +276,7 @@ module TestFrameworkId =
276276 None
277277
278278module TestItemDTO =
279- let getNormalizedFullName ( dto : TestItemDTO ) =
279+ let getFullname_withNestedParamTests ( dto : TestItemDTO ) =
280280 match dto.ExecutorUri |> TestFrameworkId.tryFromExecutorUri with
281281 // NOTE: XUnit and MSTest don't include the theory case parameters in the FullyQualifiedName, but do include them in the DisplayName.
282282 // Thus we need to append the DisplayName to differentiate the test cases
@@ -329,7 +329,7 @@ module TestResult =
329329 let ofTestResultDTO ( testResultDto : TestResultDTO ) : TestResult =
330330 let expected , actual = tryExtractExpectedAndActual testResultDto.ErrorMessage
331331
332- { FullTestName = testResultDto.TestItem |> TestItemDTO.getNormalizedFullName
332+ { FullTestName = testResultDto.TestItem |> TestItemDTO.getFullname _ withNestedParamTests
333333 Outcome = testResultDto.Outcome |> TestResultOutcome.ofOutcomeDto
334334 Output = testResultDto.AdditionalOutput
335335 ErrorMessage = testResultDto.ErrorMessage
@@ -979,7 +979,7 @@ module TestItem =
979979 let mapDtosForProject (( projectPath , targetFramework ), flatTests ) =
980980 let testDtoToNamedItem ( dto : TestItemDTO ) =
981981 {| Data = dto
982- FullName = dto |> TestItemDTO.getNormalizedFullName |}
982+ FullName = dto |> TestItemDTO.getFullname _ withNestedParamTests |}
983983
984984 let namedHierarchies =
985985 flatTests |> Array.map testDtoToNamedItem |> TestName.inferHierarchy
@@ -1426,7 +1426,42 @@ module Interactions =
14261426 builder.ToString()
14271427
14281428 let testToFilterExpression ( test : TestItem ) =
1429- let fullTestName = TestItem.getFullName test.id
1429+ let isProbableParameterizedTest ( test : TestItem ) =
1430+ match test.parent with
1431+ | None -> false
1432+ | Some parent ->
1433+ let parentPlusParentheses =
1434+ RegularExpressions.Regex( $" {parent.label |> RegularExpressions.Regex.Escape}\s *\( " )
1435+
1436+ parentPlusParentheses.IsMatch( test.label)
1437+
1438+ let getFullNameOfParameterizedTest ( test : TestItem ) =
1439+ // NOTE: For xUnit and MSTest, we're nesting the the parameterized test cases under their method name,
1440+ // but the cannonical fully qualified test name doesn't reflect this nesting, so we have to account for the parent
1441+ // There might be a better way to handle this. Perhaps dynamically adding a cannonical unique test id field to TestItem
1442+ // (like with TestFramework). Adding this to runnable TestItems would reduce edge cases and special behavior for running individual tests
1443+ let maybeGrandParent = test.parent |> Option.bind ( fun t -> t.parent)
1444+
1445+ match maybeGrandParent with
1446+ | None -> TestItem.getFullName test.id
1447+ | Some grandParent ->
1448+ TestName.appendSegment
1449+ ( TestItem.getFullName grandParent.id)
1450+ { Text = test.label
1451+ SeparatorBefore = string TestName.pathSeparator }
1452+
1453+ let getFilterPath ( test : TestItem ) =
1454+ if
1455+ ( test.TestFramework = TestFrameworkId.XUnit
1456+ || test.TestFramework = TestFrameworkId.MsTest)
1457+ && isProbableParameterizedTest test
1458+ then
1459+ getFullNameOfParameterizedTest test
1460+ else
1461+ TestItem.getFullName test.id
1462+
1463+
1464+ let fullTestName = getFilterPath test
14301465 let escapedTestName = escapeFilterExpression fullTestName
14311466
14321467 if escapedTestName.Contains( " " ) && test.TestFramework = TestFrameworkId.NUnit then
0 commit comments