Ohos test arkruntime interop testing

From openharmonyinsight/openharmony-skills · View interactive version

Ohos test arkruntime interop testing is an AI agent skill from the GitHub repository openharmonyinsight/openharmony-skills. Guide for adding and maintaining ArkTS <-> JS/TS interoperability tests in ArkCompiler. 触发场景:在 plugins/ets/tests/interop_js/tests/ 目录下创建新的 ArkTS 与 JS/TS 互操作(Interop)测试用例、调试/维护已有 Interop 测试、编写 C++ 运行器(GTest runner)或声明文件(.d.ets)时。

How to use this skill

Skill file

ETS Interop Testing

This skill provides a structured workflow and templates for creating comprehensive interop tests between ArkTS (ETS) and JavaScript/TypeScript.

Core Concepts

Interop tests typically involve three layers:

  1. C++ Runner: GTest-based entry point that manages the VM lifecycle.
  2. ArkTS (ETS) Logic: The main test code written in ArkTS.
  3. JS/TS Module: The JavaScript or TypeScript code being called or calling into ArkTS.

Directory Structure

A typical test case directory (e.g., plugins/ets/tests/interop_js/tests/my_test/) should contain:

Workflow: Adding a New Test Case

1. Initialize Directory

Create a new unique directory in plugins/ets/tests/interop_js/tests/.

2. Define JS/TS Interface

Write your JS/TS code in a .ts or .js file.

Use assets/interop_js.ts.template as a starting point.

3. Create ArkTS Declarations

If your JS/TS code exports functions/classes, create a .d.ets file to declare them for ArkTS.

Template: assets/interop_decl.d.ets.template.

4. Implement ArkTS Test Logic

Write the test logic in ArkTS. This logic should return true on success.

Template: assets/interop_test.ets.template.

5. Configure Build and Compiler

Template: assets/arktsconfig.in.json.template.

Template: assets/CMakeLists.txt.template.

6. Create C++ Runner

Inherit from EtsInteropTest and use CallEtsFunction to trigger your test.

Template: assets/test_runner.cpp.template.

Verification and Best Practices

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.