with one click
arkxtest-project-setup
// Set up arkXtest (hypium + UiTest) test modules in DevEco Studio for HarmonyOS/OpenHarmony ArkUI applications, covering ohosTest directory structure, test runner configuration, and hdc-based CLI execution.
// Set up arkXtest (hypium + UiTest) test modules in DevEco Studio for HarmonyOS/OpenHarmony ArkUI applications, covering ohosTest directory structure, test runner configuration, and hdc-based CLI execution.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | arkxtest-project-setup |
| description | Set up arkXtest (hypium + UiTest) test modules in DevEco Studio for HarmonyOS/OpenHarmony ArkUI applications, covering ohosTest directory structure, test runner configuration, and hdc-based CLI execution. |
| tech_stack | ["harmonyos"] |
| language | ["arkts","typescript","python"] |
| capability | ["unit-testing","integration-testing","ci-cd"] |
| version | OpenHarmony arkXtest API 8+ |
| collected_at | "2025-01-15T00:00:00.000Z" |
Source: https://raw.githubusercontent.com/openharmony/testfwk_arkxtest/master/README_en.md, https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V5/arkxtest-guidelines-V5, https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/hypium-python-guidelines
arkXtest is the automated test framework of OpenHarmony, providing both JsUnit (unit testing) and UiTest (UI automation). This skill covers project initialization, directory structure, and test runner setup needed to write and execute UI tests for ArkUI/ArkTS applications.
arkXtest has a two-tier design:
@ohos/hypium, running inside the device sandboxhdc (HarmonyOS Device Connector)hdc_std shell param set persist.ace.testmode.enabled 1
Tests use describe/it blocks imported from @ohos/hypium:
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default async function abilityTest() {
describe('MyTestSuite', function () {
beforeAll(function () { /* setup once */ })
beforeEach(function () { /* before each test */ })
afterEach(function () { /* after each test */ })
afterAll(function () { /* teardown once */ })
it('test_case_1', 0, function () {
expect(1 + 1).assertEqual(2)
})
})
}
| Hook | Timing |
|---|---|
beforeAll | Once before all test cases in the suite |
beforeEach | Before each individual test case |
afterEach | After each individual test case |
afterAll | Once after all test cases complete |
| API | Checks |
|---|---|
assertEqual | Actual equals expected |
assertTrue / assertFalse | Boolean value |
assertContain | Actual contains expected substring/element |
assertClose | Numeric proximity within tolerance |
assertInstanceOf | Value is of specified type |
assertNull / assertUndefined | Value is null/undefined |
assertLarger / assertLess | Greater-than / less-than |
assertThrowError | Function throws expected error |
describe(name, fn) — test suite containerit(name, filter, fn) — individual test case (filter=0 for unconditional)expect(value) — assertion entry; chain with assert methodsUiDriver.create() — UiTest entry point (see arkxtest-on-component)package.infoawait; test cases must be asyncpersist.ace.testmode.enabled must be set to 1 before UiTest executionarkxtest-on-component for component locating APIs (BY, findComponent)arkxtest-driver-interactions for click/swipe/inputText operationsarkxtest-assertions for UiComponent property assertions and Toast waiting