Skip to content

Testing

AppCube有一个内置test runner, 可以用来进行单元测试.

以后缀_test结尾的脚本是单元测试脚本,需要遵守单元测试脚本的格式。

写测试用例

ts
import { test } from "testing";
import * as assert from "assert";

test("hello world #1", function () {
    const x = 1 + 2;
    assert.equal(x, 3, "");
})

test("hello world #2", function () {
    const x = 1 + 2;
    assert.equal(x, 3, "");
})

运行测试代码

与运行普通脚本一样。输出结果如下:

json
[
    {
        "message": "",
        "name": "hello world #1",
        "success": true
    },
    {
        "message": "",
        "name": "hello world #2",
        "success": true
    }
]