harmony 鸿蒙@ohos.application.testRunner (TestRunner)

  • 2022-12-22
  • 浏览 (548)

@ohos.application.testRunner (TestRunner)

The TestRunner module provides a test framework. You can use the APIs of this module to prepare the unit test environment and run test cases.

To implement your own unit test framework, extend this class and override its APIs.

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.

Modules to Import

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

import TestRunner from '@ohos.application.testRunner';

export default class UserTestRunner implements TestRunner {
    onPrepare() {
        console.log('Trigger onPrepare');
    }
    onRun() {}
};

TestRunner.onRun

onRun(): void

Runs test cases.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Example

import TestRunner from '@ohos.application.testRunner';

export default class UserTestRunner implements TestRunner {
    onPrepare() {}
    onRun() {
        console.log('Trigger onRun');
    }
};

你可能感兴趣的鸿蒙文章

harmony 鸿蒙APIs

harmony 鸿蒙System Common Events (To Be Deprecated Soon)

harmony 鸿蒙System Common Events

harmony 鸿蒙API Reference Document Description

harmony 鸿蒙Enterprise Device Management Overview (for System Applications Only)

harmony 鸿蒙BundleStatusCallback

harmony 鸿蒙@ohos.bundle.innerBundleManager (innerBundleManager)

harmony 鸿蒙@ohos.distributedBundle (Distributed Bundle Management)

harmony 鸿蒙@ohos.bundle (Bundle)

harmony 鸿蒙@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)

0  赞