Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/mocha test reporter #305

Merged
merged 114 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
843aff7
Added expected and actual to TestResults class
chrisdp Jan 6, 2025
c74252b
First pass of MochaTestReporter
chrisdp Jan 6, 2025
6419e5d
Added actual and expected to assertTrue and assertFalse
chrisdp Jan 6, 2025
d7f97f7
New string function and more assert messages
chrisdp Jan 7, 2025
267ae90
Cleaned up message generation
chrisdp Jan 7, 2025
774bec2
Fixed failing unit test
chrisdp Jan 7, 2025
a3453ca
Cleaned up some messaging output
chrisdp Jan 7, 2025
3ed8928
Do not report empty actual and expected diffs
chrisdp Jan 7, 2025
236828e
actual and expected are invalid by default
chrisdp Jan 7, 2025
ba03d16
whitespace clean up
chrisdp Jan 7, 2025
bcd7ad5
Made temp logs less spammy
chrisdp Jan 7, 2025
8aff306
More assertion updates
chrisdp Jan 7, 2025
2e1995c
Updates to most aa and array asserts
chrisdp Jan 7, 2025
bb01de2
clean up on displaying types
chrisdp Jan 7, 2025
a6fc6e0
Updates to assertArrayCount
chrisdp Jan 7, 2025
f7ab474
Updates to assertArrayCount to fix a crash case
chrisdp Jan 7, 2025
d1f51b8
Messaging updates
chrisdp Jan 7, 2025
5fab12c
Updated array count assertions
chrisdp Jan 7, 2025
2371f13
updated assertNotEmpty and assertEmpty
chrisdp Jan 7, 2025
a577667
Fixed a actual/expected filting bug
chrisdp Jan 7, 2025
7fe4d83
Added tests to sample project
chrisdp Jan 7, 2025
2dd6bf5
Fixed a bug with assertArrayNotCount
chrisdp Jan 7, 2025
277cfe7
Updates to assertArrayContainsOnlyValuesOfType and assertType
chrisdp Jan 7, 2025
c007fb4
Fixed a bug in assertArrayContainsOnlyValuesOfType with AA's
chrisdp Jan 7, 2025
6783051
Removed stop statement
chrisdp Jan 8, 2025
9513065
updates to assertArrayNotContainsSubset, assertArrayContainsSubset, a…
chrisdp Jan 8, 2025
ab2329f
updates to assertClass and assertSubType
chrisdp Jan 8, 2025
46b87de
Fixed a bugt in assertArrayNotContainsSubset that would always fail f…
chrisdp Jan 8, 2025
f917c37
updated assertNodeCount
chrisdp Jan 8, 2025
7939844
More updates
chrisdp Jan 8, 2025
f8cd8b5
Updates assets to respect custom failure messages when supplied
chrisdp Jan 8, 2025
ecb6f66
remove only annotation
chrisdp Jan 8, 2025
679d036
Fixed a crash in eqAssocArray
chrisdp Jan 8, 2025
b380a32
Fixed some unexpected failing tests
chrisdp Jan 8, 2025
e88aca9
Fixed some failure messages for assert true and false
chrisdp Jan 8, 2025
deaf794
Tweeks to empty multiline aa and array
chrisdp Jan 8, 2025
550e06f
Fixed a crash reporting node tests due to missing actual and expected…
chrisdp Jan 9, 2025
66c4a92
Fixed a bug related to ignoredFields
chrisdp Jan 9, 2025
b2bda59
Fixed a error log that would print even when there was no error for n…
chrisdp Jan 9, 2025
795890f
Added new test reporter hooks
chrisdp Jan 10, 2025
512ca3a
implimented new hooks and moved logs into reporters
chrisdp Jan 10, 2025
0d821a4
Fixed a falure case that would pass
chrisdp Jan 10, 2025
7f95b67
Include ignored tests but skip their exicution when found
chrisdp Jan 10, 2025
4744887
Moved tests that should fail to their own suite
chrisdp Jan 10, 2025
bd83b11
Removed old commited code
chrisdp Jan 10, 2025
9855d2d
Removed an ignore anotation
chrisdp Jan 10, 2025
707e01c
Fixed some issues with skipped tests
chrisdp Jan 10, 2025
042fe6d
Updated the console test reporter to handle skipped and ignored tests…
chrisdp Jan 10, 2025
99171b3
Fixed a regression in the console test reporter
chrisdp Jan 10, 2025
511d073
Merge branch 'master' into feature/mocha-test-reporter
chrisdp Jan 10, 2025
8ae8b59
Fixed some broken tests
chrisdp Jan 10, 2025
a06bb33
Re-enabled catch on crash
chrisdp Jan 10, 2025
7e0730a
Added new colorizeOutput setting
chrisdp Jan 13, 2025
08a4af1
Formatting fixes
chrisdp Jan 13, 2025
96632fa
linking fixes
chrisdp Jan 13, 2025
f136a16
replaced short hand prints
chrisdp Jan 13, 2025
1ae302f
Moved diffing logic into an internal namespace to prevent code conflicts
chrisdp Jan 13, 2025
e127312
Code clean up
chrisdp Jan 13, 2025
575586e
Updated reporters to take event objects
chrisdp Jan 13, 2025
6dd854e
Updated brighterscript to 0.68.3
chrisdp Jan 13, 2025
4227065
Updated brighterscript to 0.68.3 for test workspace
chrisdp Jan 13, 2025
9b80589
Added a log that will always fire after test reporters
chrisdp Jan 13, 2025
2f72715
Removed some unnessisary prints from mocha reporter
chrisdp Jan 13, 2025
0ae9a04
Doc blocks
chrisdp Jan 13, 2025
be41856
Made stacktraces easier to read and added test file links in crashes
chrisdp Jan 13, 2025
1a163d1
Typo
chrisdp Jan 13, 2025
a0e0fde
More tests
chrisdp Jan 13, 2025
df8b66d
Removed actual and expected from assertNotEqual
chrisdp Jan 13, 2025
87f4689
More failure tests
chrisdp Jan 13, 2025
2ce1601
More failure tests for assertArrayNotContains
chrisdp Jan 13, 2025
daa700a
Cleaned up some tests
chrisdp Jan 14, 2025
5cc1f29
Fixed assertAANotHasKey not marking tests as failed in some cases
chrisdp Jan 14, 2025
60722f1
Fixed crash in assertInvalid
chrisdp Jan 14, 2025
b64f834
Added actual and expected diff for assertAAHasKeys
chrisdp Jan 14, 2025
7ad40e8
Cleaned up some failure messages
chrisdp Jan 14, 2025
0aba70e
More tests and clean up for failed assertions
chrisdp Jan 14, 2025
d8ef0a1
Updated asMultilineString to print invalid and uninitialized as their…
chrisdp Jan 14, 2025
efadf5d
comment typo
chrisdp Jan 14, 2025
d460a87
Code clean up and lots more comments in mocha test reporter
chrisdp Jan 14, 2025
0a2a063
Fixed the reports namespace name to be reporter
chrisdp Jan 14, 2025
fddad40
Moved some logs to a new warning log rather then error
chrisdp Jan 14, 2025
f233caf
updated assertClass to remove actual and expected diff
chrisdp Jan 14, 2025
a4c2a27
Fixed uninitilized not being comparable with eqValues
chrisdp Jan 14, 2025
b77ad70
Fixed mocha results printing
chrisdp Jan 14, 2025
aca45ca
Fixed most failing tests
chrisdp Jan 14, 2025
119a216
Update CommonUtils.bs
chrisdp Jan 15, 2025
120dbc6
Update CommonUtils.bs
chrisdp Jan 15, 2025
154c125
Update TestGroup.bs
chrisdp Jan 15, 2025
9d3404f
Update CodeCoverageProcessor.spec.ts
chrisdp Jan 15, 2025
d23bae0
added fast glob npm module
chrisdp Jan 15, 2025
bd34cd4
updated FileFactory to use flog to find framework files
chrisdp Jan 15, 2025
69a461d
Updated the framework fold structure to match what will be on device
chrisdp Jan 15, 2025
4fd2173
Fixed build copy command
chrisdp Jan 15, 2025
1a49edc
Code clean up and removed unessisary props following the structure ch…
chrisdp Jan 15, 2025
adda058
Removed options from FileFactory constructor
chrisdp Jan 15, 2025
bdd7a2f
Merge branch 'task/update-framework-folder-to-match-structure-on-devi…
chrisdp Jan 15, 2025
be7864d
Moved MochaTestReporter class into source/rooibos
chrisdp Jan 15, 2025
0818b87
Added a couple passing tests for assertInvalid
chrisdp Jan 15, 2025
5458f56
Always sort keys in aa when generating diff strings
chrisdp Jan 15, 2025
c574196
Added support for reporting slow tests
chrisdp Jan 15, 2025
052b5b0
Fixed failing test
chrisdp Jan 15, 2025
daa52a8
Fixed an issue where identical diffs would attempt to be rendered
chrisdp Jan 17, 2025
d0b2be6
Moved back to brighterscript 0.67.4
chrisdp Jan 20, 2025
5bc1af7
Fixed typos in docs
chrisdp Jan 20, 2025
68a7138
Added doc for slow annotation
chrisdp Jan 20, 2025
3f387f6
Added tons of tests for passing usecases
chrisdp Jan 20, 2025
b1a3b57
Update bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.spec.ts
chrisdp Jan 20, 2025
6b91e29
New line when tests start
chrisdp Jan 20, 2025
1c7063e
Added assertNotInvalid test for roInvalid
chrisdp Jan 22, 2025
cba39ca
Updated assertInvalid test for roInvalid
chrisdp Jan 22, 2025
b5506e6
hardened assertNotInvalid and fixed assertInvalid for roInvalid
chrisdp Jan 22, 2025
e5f43b4
Fixed some off by oneline number reporting bugs
chrisdp Jan 22, 2025
2f1711e
Merge branch 'master' of https://github.com/rokucommunity/rooibos int…
TwitchBronBron Jan 28, 2025
9b80edf
Use more cross-platform compatible x char
TwitchBronBron Jan 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
217 changes: 188 additions & 29 deletions bsc-plugin/package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions bsc-plugin/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ async function main() {
await telnet.activate();
await telnet.connect();

const failRegex = /RESULT: Fail/g;
const endRegex = /\[END TEST REPORT\]/g;
const failRegex = /\[Rooibos Result\]: (FAIL|PASS)/g;
const endRegex = /\[Rooibos Shutdown\]/g;

async function doExit(emitAppExit = false) {
if (emitAppExit) {
Expand All @@ -82,7 +82,9 @@ async function main() {
//check for Fails or Crashes
let failMatches = failRegex.exec(output);
if (failMatches && failMatches.length > 0) {
currentErrorCode = 1;
if (failMatches[1] === 'FAIL') {
currentErrorCode = 1;
}
}

let endMatches = endRegex.exec(output);
Expand Down
23 changes: 21 additions & 2 deletions bsc-plugin/src/lib/rooibos/Annotation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AnnotationExpression, BrsFile, Statement } from 'brighterscript';
import { diagnosticIllegalParams, diagnosticNoTestNameDefined, diagnosticMultipleDescribeAnnotations, diagnosticMultipleTestOnFunctionDefined } from '../utils/Diagnostics';
import { diagnosticIllegalParams, diagnosticNoTestNameDefined, diagnosticMultipleDescribeAnnotations, diagnosticMultipleTestOnFunctionDefined, diagnosticSlowAnnotationRequiresNumber } from '../utils/Diagnostics';

export enum AnnotationType {
None = 'none',
Expand All @@ -9,6 +9,7 @@ export enum AnnotationType {
Ignore = 'ignore',
Solo = 'only',
NodeTest = 'sgnode',
Slow = 'slow',
Setup = 'setup',
TearDown = 'teardown',
BeforeEach = 'beforeeach',
Expand All @@ -30,6 +31,7 @@ let annotationLookup = {
only: AnnotationType.Solo,
sgnode: AnnotationType.NodeTest,
setup: AnnotationType.Setup,
slow: AnnotationType.Slow,
teardown: AnnotationType.TearDown,
beforeeach: AnnotationType.BeforeEach,
aftereach: AnnotationType.AfterEach,
Expand All @@ -47,6 +49,8 @@ interface ParsedComment {
testAnnotation?: RooibosAnnotation;
}

const defaultSlowDuration = 75;

export class AnnotationParams {

constructor(
Expand Down Expand Up @@ -82,7 +86,8 @@ export class RooibosAnnotation {
public nodeName?: string,
rawTags: string[] = [],
public noCatch = false,
public noEarlyExit = false
public noEarlyExit = false,
public slow = defaultSlowDuration
) {
this.tags = new Set<string>(rawTags);
}
Expand Down Expand Up @@ -192,6 +197,20 @@ export class RooibosAnnotation {
//error
}
}

for (const annotation of getAnnotationsOfType(AnnotationType.Slow)) {
if (testAnnotation) {
let slow = annotation.getArguments().length === 1 ? parseInt(annotation.getArguments()[0] as any) : defaultSlowDuration;
if (isNaN(slow)) {
diagnosticSlowAnnotationRequiresNumber(file, annotation);
testAnnotation.slow = defaultSlowDuration;
} else {
testAnnotation.slow = slow;
}
} else {
//error
}
}
}
}
return { blockAnnotation: blockAnnotation, testAnnotation: testAnnotation };
Expand Down
4 changes: 2 additions & 2 deletions bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ describe('RooibosPlugin', () => {
it('adds code coverage to a brs file', async () => {
program.setFile('source/code.brs', `
function new(a1, a2)
c = 0
text = ""
c = 0
text = ""
for i = 0 to 10
text = text + "hello"
c++
Expand Down
8 changes: 7 additions & 1 deletion bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class CodeCoverageProcessor {
private coverageMap: Map<number, number>;
private fileFactory: FileFactory;
private processedStatements: Set<Statement>;
private addedStatements: Set<Statement>;
private astEditor: Editor;

public generateMetadata(isUsingCoverage: boolean, program: Program) {
Expand All @@ -74,6 +75,7 @@ export class CodeCoverageProcessor {
this.coverageMap = new Map<number, number>();
this.executableLines = new Map<number, Statement>();
this.processedStatements = new Set<Statement>();
this.addedStatements = new Set<Statement>();
this.astEditor = astEditor;

file.ast.walk(createVisitor({
Expand Down Expand Up @@ -167,21 +169,25 @@ export class CodeCoverageProcessor {
}

private convertStatementToCoverageStatement(statement: Statement, coverageType: CodeCoverageLineType, owner: any, key: any) {
if (this.processedStatements.has(statement)) {
if (this.processedStatements.has(statement) || this.addedStatements.has(statement)) {
return;
}

const lineNumber = statement.range.start.line;
this.coverageMap.set(lineNumber, coverageType);
const parsed = Parser.parse(this.getFuncCallText(lineNumber, coverageType)).ast.statements[0] as ExpressionStatement;
this.astEditor.arraySplice(owner, key, 0, parsed);
this.addedStatements.add(parsed);
// store the statement in a set to avoid handling again after inserting statement above
this.processedStatements.add(statement);
}

public addBrsAPIText(file: BrsFile, astEditor: Editor) {
const astCodeToInject = Parser.parse(this.coverageBrsTemplate.replace(/\#ID\#/g, this.fileId.toString().trim())).ast.statements;
astEditor.arrayPush(file.ast.statements, ...astCodeToInject);
for (let statement of astCodeToInject) {
this.addedStatements.add(statement);
}
}

private addStatement(statement: Statement, lineNumber?: number) {
Expand Down
4 changes: 4 additions & 0 deletions bsc-plugin/src/lib/rooibos/RawCodeExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export class RawCodeExpression extends Expression {
super();
}

public clone() {
return new RawCodeExpression(this.source, this.sourceFile, this.range);
}

public transpile(state: BrsTranspileState) {
return [new SourceNode(
this.range.start.line + 1,
Expand Down
4 changes: 4 additions & 0 deletions bsc-plugin/src/lib/rooibos/RawCodeStatement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export class RawCodeStatement extends Statement {
super();
}

public clone() {
return new RawCodeStatement(this.source, this.sourceFile, this.range);
}

public transpile(state: BrsTranspileState) {
//indent every line with the current transpile indent level (except the first line, because that's pre-indented by bsc)
let source = this.source.replace(/\r?\n/g, (match, newline) => {
Expand Down
1 change: 1 addition & 0 deletions bsc-plugin/src/lib/rooibos/RooibosConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface RooibosConfig {
includeFilters?: string[];
tags?: string[];
catchCrashes?: boolean;
colorizeOutput?: boolean;
throwOnFailedAssertion?: boolean;
sendHomeOnFinish?: boolean;

Expand Down
2 changes: 2 additions & 0 deletions bsc-plugin/src/lib/rooibos/RooibosSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export class RooibosSession {
"printLcov": ${this.config.printLcov ? 'true' : 'false'}
"port": "${this.config.port || 'invalid'}"
"catchCrashes": ${this.config.catchCrashes ? 'true' : 'false'}
"colorizeOutput": ${this.config.colorizeOutput ? 'true' : 'false'}
"throwOnFailedAssertion": ${this.config.throwOnFailedAssertion ? 'true' : 'false'}
"keepAppOpen": ${this.config.keepAppOpen === undefined || this.config.keepAppOpen ? 'true' : 'false'}
"isRecordingCodeCoverage": ${this.config.isRecordingCodeCoverage ? 'true' : 'false'}
Expand Down Expand Up @@ -174,6 +175,7 @@ export class RooibosSession {
switch (name.toLowerCase()) {
case 'console': return 'rooibos_ConsoleTestReporter';
case 'junit': return 'rooibos_JUnitTestReporter';
case 'mocha': return 'rooibos_MochaTestReporter';
}
// @todo: check if function name is valid
return name;
Expand Down
101 changes: 56 additions & 45 deletions bsc-plugin/src/lib/rooibos/RooibosSessionInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class SessionInfo {
} else if (this.hasSoloSuites && !testSuite.isSolo) {
testSuite.isIncluded = false;
} else if (testSuite.isIgnored) {
testSuite.isIncluded = false;
testSuite.isIncluded = true;
this.ignoredTestNames.push(testSuite.name + ' [WHOLE SUITE]');
this.ignoredCount++;
} else {
Expand All @@ -88,62 +88,73 @@ export class SessionInfo {
}
//'testSuite ' + testSuite.name);
for (let testGroup of testSuite.getTestGroups()) {
if (testSuite.isIgnored) {
testGroup.isIgnored = true;
}

//'GROUP ' + testGroup.name);
if (testGroup.isIgnored) {
this.ignoredCount += testGroup.ignoredTestCases.length;
this.ignoredTestNames.push(testGroup.name + ' [WHOLE GROUP]');
testGroup.isIncluded = false;
} else {
if (testGroup.ignoredTestCases.length > 0) {
this.ignoredTestNames.push(testGroup.name);
this.ignoredCount += testGroup.ignoredTestCases.length;
for (let ignoredTestCase of testGroup.ignoredTestCases) {
if (!ignoredTestCase.isParamTest) {
this.ignoredTestNames.push(ignoredTestCase.name);
} else if (ignoredTestCase.paramTestIndex === 0) {
let testCaseName = ignoredTestCase.name;
if (testCaseName.length > 1 && testCaseName.substr(testCaseName.length - 1) === '0') {
testCaseName = testCaseName.substr(0, testCaseName.length - 1);
}
this.ignoredTestNames.push(testCaseName);
testGroup.isIncluded = true;
}

if (testGroup.ignoredTestCases.length > 0) {
this.ignoredTestNames.push(testGroup.name);
this.ignoredCount += testGroup.ignoredTestCases.length;
for (let ignoredTestCase of testGroup.ignoredTestCases) {
if (!ignoredTestCase.isParamTest) {
this.ignoredTestNames.push(ignoredTestCase.name);
} else if (ignoredTestCase.paramTestIndex === 0) {
let testCaseName = ignoredTestCase.name;
if (testCaseName.length > 1 && testCaseName.substr(testCaseName.length - 1) === '0') {
testCaseName = testCaseName.substr(0, testCaseName.length - 1);
}
this.ignoredTestNames.push(testCaseName);
}
}
if (this.isExcludedByTag(testGroup, true)) {
testGroup.isIncluded = false;
} else if (this.hasSoloTests && !testGroup.hasSoloTests) {
testGroup.isIncluded = false;
} else if (this.hasSoloGroups && !testGroup.isSolo) {
testGroup.isIncluded = false;
} else {
testGroup.isIncluded = true;
}
if (this.isExcludedByTag(testGroup, true)) {
testGroup.isIncluded = false;
} else if (this.hasSoloTests && !testGroup.hasSoloTests) {
testGroup.isIncluded = false;
} else if (this.hasSoloGroups && !testGroup.isSolo) {
testGroup.isIncluded = false;
} else {
testGroup.isIncluded = true;
}

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

for (let testCase of testCases) {
if (testGroup.isIgnored) {
testCase.isIgnored = true;
}

if (this.isExcludedByTag(testCase, true)) {
testCase.isIncluded = false;
} else if (testCase.isIgnored) {
testCase.isIncluded = true;
} else if (this.hasSoloTests && !testCase.isSolo) {
testCase.isIncluded = false;
} else {
testCase.isIncluded = testGroup.isIncluded || testCase.isSolo;
}
}

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

for (let testCase of testCases) {
if (this.isExcludedByTag(testCase, true)) {
testCase.isIncluded = false;
} else if (testCase.isIgnored) {
testCase.isIncluded = false;
} else if (this.hasSoloTests && !testCase.isSolo) {
testCase.isIncluded = false;
} else {
testCase.isIncluded = testGroup.isIncluded || testCase.isSolo;
this.testsCount++;
}
for (let testCase of testGroup.soloTestCases) {
if (this.isExcludedByTag(testCase, true)) {
testCase.isIncluded = false;
} else {
testCase.isIncluded = true;
}
}

for (let testCase of testGroup.soloTestCases) {
if (this.isExcludedByTag(testCase, true)) {
testCase.isIncluded = false;
} else {
testCase.isIncluded = true;
this.testsCount++;
}
for (let testCase of testCases) {
if (testCase.isIncluded) {
this.testsCount++;
}
}
}
Expand Down
15 changes: 5 additions & 10 deletions bsc-plugin/src/lib/rooibos/TestCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export class TestCase {
this.isSolo = isSolo;
this.isAsync = annotation.isAsync;
this.asyncTimeout = annotation.asyncTimeout;
this.slow = annotation.slow;
this.funcName = funcName;
this.isIgnored = isIgnored;
this.name = name;
this.lineNumber = lineNumber;
this.paramLineNumber = paramLineNumber;
this.assertIndex = 0;
this.assertLineNumberMap = {};
this.rawParams = params;
this.expectedNumberOfParams = expectedNumberOfParams;
this.paramTestIndex = paramTestIndex;
Expand All @@ -30,12 +30,12 @@ export class TestCase {
public isParamTest: boolean;
public isAsync: boolean;
public asyncTimeout: number;
public slow: number;
public name: string;
public lineNumber: number;
public paramLineNumber: number;
public assertIndex: number;
public expectedNumberOfParams: number;
public assertLineNumberMap: any;
public rawParams: any[];
public paramTestIndex: number;

Expand All @@ -50,24 +50,19 @@ export class TestCase {
isIgnored: ${this.isIgnored}
isAsync: ${this.isAsync}
asyncTimeout: ${this.asyncTimeout || 2000}
slow: ${this.slow}
isParamTest: ${this.isParamTest}
name: ${sanitizeBsJsonString(this.name)}
lineNumber: ${this.lineNumber + 2}
paramLineNumber: ${this.paramLineNumber}
lineNumber: ${this.lineNumber + 1}
paramLineNumber: ${this.isParamTest ? this.paramLineNumber + 1 : 0}
assertIndex: ${this.assertIndex}
assertLineNumberMap: ${JSON.stringify(this.assertLineNumberMap)}
rawParams: ${rawParamsText}
paramTestIndex: ${this.paramTestIndex}
expectedNumberOfParams: ${this.expectedNumberOfParams}
isParamsValid: ${(this.rawParams || []).length === this.expectedNumberOfParams}
}`;
}

public addAssertLine(lineNumber: number) {
this.assertLineNumberMap[this.assertIndex.toString().trim()] = lineNumber;
this.assertIndex++;
}

fixBadJson(o) {
// In case of an array we'll stringify all objects.
if (Array.isArray(o)) {
Expand Down
5 changes: 3 additions & 2 deletions bsc-plugin/src/lib/rooibos/TestGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class TestGroup extends TestBlock {
if (testCase.isIgnored) {
this.ignoredTestCases.push(testCase);
this.hasIgnoredTests = true;
this.soloTestCases.push(testCase);
} else if (testCase.isSolo) {
this.hasSoloTests = true;
this.soloTestCases.push(testCase);
Expand Down Expand Up @@ -78,7 +79,7 @@ export class TestGroup extends TestBlock {
const trailingLine = Parser.parse(`if m.currentResult?.isFail = true then m.done() : return ${isSub ? '' : 'invalid'}`).ast.statements[0];
editor.arraySplice(owner, key + 1, 0, trailingLine);
}
const leadingLine = Parser.parse(`m.currentAssertLineNumber = ${callExpression.range.start.line}`).ast.statements[0];
const leadingLine = Parser.parse(`m.currentAssertLineNumber = ${callExpression.range.start.line + 1}`).ast.statements[0];
editor.arraySplice(owner, key, 0, leadingLine);
}
}
Expand Down Expand Up @@ -220,7 +221,7 @@ export class TestGroup extends TestBlock {
isSolo: ${this.isSolo}
isIgnored: ${this.isIgnored}
filename: "${this.pkgPath}"
lineNumber: "${this.annotation.annotation.range.start.line}"
lineNumber: "${this.annotation.annotation.range.start.line + 1}"
setupFunctionName: "${this.setupFunctionName || ''}"
tearDownFunctionName: "${this.tearDownFunctionName || ''}"
beforeEachFunctionName: "${this.beforeEachFunctionName || ''}"
Expand Down
Loading
Loading