Skip to content

Commit

Permalink
Added the ability to have duplicate test names (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron authored Feb 24, 2025
2 parents b3998f3 + 1141def commit cdbba6a
Show file tree
Hide file tree
Showing 10 changed files with 898 additions and 863 deletions.
2 changes: 1 addition & 1 deletion bsc-plugin/src/lib/rooibos/MockUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class MockUtil {
gatherGlobalMethodMocks(testSuite: TestSuite) {
// console.log('gathering global method mocks for testSuite', testSuite.name);
for (let group of [...testSuite.testGroups.values()].filter((tg) => tg.isIncluded)) {
for (let testCase of [...group.testCases.values()].filter((tc) => tc.isIncluded)) {
for (let testCase of [...group.testCases].filter((tc) => tc.isIncluded)) {
this.gatherMockedGlobalMethods(testSuite, testCase);
}
}
Expand Down
4 changes: 2 additions & 2 deletions bsc-plugin/src/lib/rooibos/RooibosSessionInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ export class SessionInfo {
testGroup.isIncluded = true;
if (testGroup.isIgnored) {
this.ignoredTestNames.push(testGroup.name + ' [WHOLE GROUP]');
this.ignoredCount += testGroup.testCases.size;
this.ignoredCount += testGroup.testCases.length;
}
}

if (testGroup.isIncluded) {
if (testGroup.isIncluded) {
this.groupsCount++;
}
let testCases = [...testGroup.testCases.values()];
let testCases = [...testGroup.testCases];

for (let testCase of testCases) {
testCase.isIncluded = false;
Expand Down
10 changes: 3 additions & 7 deletions bsc-plugin/src/lib/rooibos/TestGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,15 @@ export class TestGroup extends TestBlock {
}

public testSuite: TestSuite;
public testCases = new Map<string, TestCase>();
public testCases: Array<TestCase> = [];

public addTestCase(testCase: TestCase) {
this.testCases.set(testCase.name + (testCase.isParamTest ? testCase.paramTestIndex.toString() : ''), testCase);
this.testCases.push(testCase);
this.hasIgnoredTests = this.hasIgnoredTests || testCase.isIgnored;
this.hasSoloTests = this.hasSoloTests || testCase.isSolo;
this.hasAsyncTests = this.hasAsyncTests || testCase.isAsync;
}

public getTestCases(): TestCase[] {
return [...this.testCases.values()];
}

public modifyAssertions(testCase: TestCase, noEarlyExit: boolean, editor: AstEditor, namespaceLookup: Map<string, NamespaceContainer>, scope: Scope) {
//for each method
//if assertion
Expand Down Expand Up @@ -201,7 +197,7 @@ export class TestGroup extends TestBlock {
}

public asText(): string {
let testCaseText = [...this.testCases.values()].filter((tc) => tc.isIncluded).map((tc) => tc.asText());
let testCaseText = [...this.testCases].filter((tc) => tc.isIncluded).map((tc) => tc.asText());

return `
{
Expand Down
1 change: 1 addition & 0 deletions bsc-plugin/src/lib/rooibos/TestSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class TestSuite extends TestBlock {
public hasSoloGroups = false;
public isNodeTest = false;
public session: RooibosSession;
public registeredTestCount = 0;

public addGroup(group: TestGroup) {
this.testGroups.set(group.name, group);
Expand Down
Loading

0 comments on commit cdbba6a

Please sign in to comment.