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 28import TestRunner from '@ohos.application.testRunner'; 29 30export default class UserTestRunner implements TestRunner { 31 onPrepare() { 32 console.log('Trigger onPrepare'); 33 } 34 onRun() {} 35}; 36``` 37 38 39 40## TestRunner.onRun 41 42onRun(): void 43 44Runs test cases. 45 46**System capability**: SystemCapability.Ability.AbilityRuntime.Core 47 48**Example** 49 50```ts 51import TestRunner from '@ohos.application.testRunner'; 52 53export default class UserTestRunner implements TestRunner { 54 onPrepare() {} 55 onRun() { 56 console.log('Trigger onRun'); 57 } 58}; 59``` 60