• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# TestRunner
2
3> **Note**
4>
5> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
6
7## Modules to Import
8
9```js
10import TestRunner from '@ohos.application.testRunner'
11```
12
13
14
15## TestRunner.onPrepare
16
17onPrepare(): void
18
19Prepares the unit test environment to run test cases.
20
21**System capability**: SystemCapability.Ability.AbilityRuntime.Core
22
23**Example**
24
25```js
26export default class UserTestRunner extends TestRunner {
27    onPrepare() {
28        console.log("Trigger onPrepare")
29    }
30};
31```
32
33
34
35## TestRunner.onRun
36
37onRun(): void
38
39Runs test cases.
40
41**System capability**: SystemCapability.Ability.AbilityRuntime.Core
42
43**Example**
44
45```js
46export default class UserTestRunner extends TestRunner {
47    onRun() {
48        console.log("Trigger onRun")
49    }
50};
51```
52