1212//
1313//===----------------------------------------------------------------------===//
1414
15+ import * as assert from "assert" ;
1516import * as vscode from "vscode" ;
1617import { beforeEach , afterEach } from "mocha" ;
1718import { testAssetUri } from "../../fixtures" ;
@@ -35,6 +36,11 @@ import {
3536 TestSymbol ,
3637} from "../../../src/TestExplorer/TestParsers/SwiftTestingOutputParser" ;
3738import { mockGlobalObject } from "../../MockUtils" ;
39+ import {
40+ flattenTestItemCollection ,
41+ reduceTestItemChildren ,
42+ } from "../../../src/TestExplorer/TestUtils" ;
43+ import { runnableTag } from "../../../src/TestExplorer/TestDiscovery" ;
3844
3945suite ( "Test Explorer Suite" , function ( ) {
4046 const MAX_TEST_RUN_TIME_MINUTES = 5 ;
@@ -513,16 +519,13 @@ suite("Test Explorer Suite", function () {
513519 } ) ;
514520
515521 test ( `Runs parameterized test (${ runProfile } )` , async function ( ) {
516- const testRun = await runTest (
517- testExplorer ,
518- runProfile ,
519- "PackageTests.parameterizedTest(_:)"
520- ) ;
522+ const testId = "PackageTests.parameterizedTest(_:)" ;
523+ const testRun = await runTest ( testExplorer , runProfile , testId ) ;
521524
522525 assertTestResults ( testRun , {
523526 passed : [
524- "PackageTests.parameterizedTest(_:) /PackageTests.swift:59:2/argumentIDs: Optional([Testing.Test.Case.Argument.ID(bytes: [49])])" ,
525- "PackageTests.parameterizedTest(_:) /PackageTests.swift:59:2/argumentIDs: Optional([Testing.Test.Case.Argument.ID(bytes: [51])])" ,
527+ ` ${ testId } /PackageTests.swift:59:2/argumentIDs: Optional([Testing.Test.Case.Argument.ID(bytes: [49])])` ,
528+ ` ${ testId } /PackageTests.swift:59:2/argumentIDs: Optional([Testing.Test.Case.Argument.ID(bytes: [51])])` ,
526529 ] ,
527530 failed : [
528531 {
@@ -532,14 +535,37 @@ suite("Test Explorer Suite", function () {
532535 text : "Expectation failed: (arg → 2) != 2" ,
533536 } ) } `,
534537 ] ,
535- test : "PackageTests.parameterizedTest(_:) /PackageTests.swift:59:2/argumentIDs: Optional([Testing.Test.Case.Argument.ID(bytes: [50])])" ,
538+ test : ` ${ testId } /PackageTests.swift:59:2/argumentIDs: Optional([Testing.Test.Case.Argument.ID(bytes: [50])])` ,
536539 } ,
537540 {
538541 issues : [ ] ,
539- test : "PackageTests.parameterizedTest(_:)" ,
542+ test : testId ,
540543 } ,
541544 ] ,
542545 } ) ;
546+
547+ // Verifiy that the children of the parameterized test are not runnable
548+ const parameterizedTestItem = flattenTestItemCollection (
549+ testExplorer . controller . items
550+ ) . find ( item => item . id === testId ) ;
551+
552+ assert . ok (
553+ parameterizedTestItem ,
554+ `Unable to find ${ testId } in test explorer children`
555+ ) ;
556+
557+ const unrunnableChildren = reduceTestItemChildren (
558+ parameterizedTestItem ?. children ?? [ ] ,
559+ ( acc , item ) => {
560+ return [
561+ ...acc ,
562+ item . tags . find ( tag => tag . id === runnableTag . id ) === undefined ,
563+ ] ;
564+ } ,
565+ [ ] as boolean [ ]
566+ ) ;
567+
568+ assert . deepEqual ( unrunnableChildren , [ true , true , true ] ) ;
543569 } ) ;
544570
545571 test ( `Runs Suite (${ runProfile } )` , async function ( ) {
0 commit comments