1# @ohos.application.testRunner (TestRunner) 2 3The **TestRunner** module provides a test framework. You can use the APIs of this module to prepare the unit test environment and run test cases. 4 5To implement your own unit test framework, extend this class and override its APIs. 6 7> **NOTE** 8> 9> 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. 10 11## Modules to Import 12 13```ts 14import TestRunner from '@ohos.application.testRunner'; 15``` 16 17## TestRunner.onPrepare 18 19onPrepare(): void 20 21Prepares the unit test environment to run test cases. 22 23**System capability**: SystemCapability.Ability.AbilityRuntime.Core 24 25**Example** 26 27```ts 28export default class UserTestRunner implements TestRunner { 29 onPrepare() { 30 console.log('Trigger onPrepare'); 31 } 32 onRun() {} 33}; 34``` 35 36 37 38## TestRunner.onRun 39 40onRun(): void 41 42Runs test cases. 43 44**System capability**: SystemCapability.Ability.AbilityRuntime.Core 45 46**Example** 47 48```ts 49export default class UserTestRunner implements TestRunner { 50 onPrepare() {} 51 onRun() { 52 console.log('Trigger onRun'); 53 } 54}; 55``` 56