Skip to content

Commit ed83bf9

Browse files
committed
register test function
1 parent 1e09dec commit ed83bf9

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

assembly/env.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export namespace assertResult {
77
@external("__unittest_framework_env","removeDescription")
88
export declare function removeDescription(): void;
99

10+
@external("__unittest_framework_env","registerTestFunction")
11+
export declare function registerTestFunction(index: u32): void;
1012

1113
@external("__unittest_framework_env","collectCheckResult")
1214
export declare function collectCheckResult(

assembly/implement.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export function describeImpl(
1111
}
1212
export function testImpl(description: string, testFunction: () => void): void {
1313
assertResult.addDescription(description);
14+
assertResult.registerTestFunction(testFunction.index);
1415
testFunction();
1516
assertResult.removeDescription();
1617
mockFunctionStatus.clear();

src/core/executionRecorder.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export class ExecutionRecorder implements IAssertResult {
55
total: number = 0;
66
fail: number = 0;
77
failed_info: AssertFailMessage = {};
8+
registerFunctions: [string, number][] = [];
89
_currentTestDescriptions: string[] = [];
910

1011
_addDescription(description: string): void {
@@ -13,6 +14,10 @@ export class ExecutionRecorder implements IAssertResult {
1314
_removeDescription(): void {
1415
this._currentTestDescriptions.pop();
1516
}
17+
registerTestFunction(fncIndex: number): void {
18+
const testCaseFullName = this._currentTestDescriptions.join(" - ");
19+
this.registerFunctions.push([testCaseFullName, fncIndex]);
20+
}
1621
collectCheckResult(result: boolean, codeInfoIndex: number, actualValue: string, expectValue: string): void {
1722
this.total++;
1823
if (!result) {
@@ -33,6 +38,9 @@ export class ExecutionRecorder implements IAssertResult {
3338
removeDescription: (): void => {
3439
this._removeDescription();
3540
},
41+
registerTestFunction: (index: number): void => {
42+
this.registerTestFunction(index);
43+
},
3644
collectCheckResult: (result: number, codeInfoIndex: number, actualValue: number, expectValue: number): void => {
3745
this.collectCheckResult(
3846
result !== 0,

0 commit comments

Comments
 (0)