TestRunner
TestRunner模塊提供了框架測試的能力。包括準備單元測試環境、運行測試用例。
如果您想實現自己的單元測試框架,您必須繼承這個類并覆蓋它的所有方法。
說明:
開發前請熟悉鴻蒙開發指導文檔:gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md
點擊或者復制轉到。
本模塊首批接口從API version 8開始支持。后續版本的新增接口,采用上角標單獨標記接口的起始版本。
導入模塊
import TestRunner from '@ohos.application.testRunner'
TestRunner.onPrepare
onPrepare(): void
為運行測試用例準備單元測試環境
系統能力: SystemCapability.Ability.AbilityRuntime.Core
示例:
export default class UserTestRunner implements TestRunner {onPrepare() {console.log("Trigger onPrepare")}
onRun(){}
};
TestRunner.onRun
onRun(): void
運行測試用例
系統能力: SystemCapability.Ability.AbilityRuntime.Core
示例:
export default class UserTestRunner implements TestRunner {onPrepare() {console.log("Trigger onRun")}
onRun(){}
};