1# TestRunner 2 3> **说明** 4> 5> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 6 7## 导入模块 8 9```js 10import TestRunner from '@ohos.application.testRunner' 11``` 12 13 14 15## TestRunner.onPrepare 16 17onPrepare(): void 18 19为运行测试用例准备单元测试环境 20 21**系统能力:** SystemCapability.Ability.AbilityRuntime.Core 22 23**示例:** 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 39运行测试用例 40 41**系统能力:** SystemCapability.Ability.AbilityRuntime.Core 42 43**示例:** 44 45```js 46export default class UserTestRunner extends TestRunner { 47 onRun() { 48 console.log("Trigger onRun") 49 } 50}; 51``` 52