js-apis-testRunner.md 861 字节
Newer Older
W
wusongqing 已提交
1 2
# TestRunner

W
wusongqing 已提交
3 4 5
> **NOTE**
> 
> 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. 
W
wusongqing 已提交
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

## Modules to Import

```js
import TestRunner from '@ohos.application.testRunner'
```



## TestRunner.onPrepare

onPrepare(): void

Prepares the unit test environment to run test cases.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Example**

```js
export default class UserTestRunner extends TestRunner {
    onPrepare() {
        console.log("Trigger onPrepare")
    }
};
```



## TestRunner.onRun

onRun(): void

Runs test cases.

**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**Example**

```js
export default class UserTestRunner extends TestRunner {
    onRun() {
        console.log("Trigger onRun")
    }
};
```