Skip to content

Commit b8e8e1c

Browse files
authored
Test parameterized test children aren't runnable (#1158)
Add on to the parameterized integration test to verify that there is a test case added for each argument, and that they are not runnable.
1 parent 4d5113b commit b8e8e1c

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

test/integration-tests/testexplorer/TestExplorerIntegration.test.ts

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
import * as assert from "assert";
1516
import * as vscode from "vscode";
1617
import { beforeEach, afterEach } from "mocha";
1718
import { testAssetUri } from "../../fixtures";
@@ -35,6 +36,11 @@ import {
3536
TestSymbol,
3637
} from "../../../src/TestExplorer/TestParsers/SwiftTestingOutputParser";
3738
import { mockGlobalObject } from "../../MockUtils";
39+
import {
40+
flattenTestItemCollection,
41+
reduceTestItemChildren,
42+
} from "../../../src/TestExplorer/TestUtils";
43+
import { runnableTag } from "../../../src/TestExplorer/TestDiscovery";
3844

3945
suite("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

Comments
 (0)