如何从单独的 class 进行 TestRunner 拉取测试

How to make TestRunner pull tests from a separate class

我目前有一个 TestRunner (from ceylon.test) 可以从本地函数进行测试。现在我试图让它发现嵌入在单独文件中的 class 中的测试。但是,TestRunner 没有从 class 中找到测试,我不知道如何调试它。没有编译器错误。我该如何开始调试这个问题?

这是相关文件的文件+文件夹结构:

source/
 - designs/
  - BoundedPlane_test.ceylon
  - module.ceylon
  - package.ceylon
 - tests/
  - module.ceylon
  - package.ceylon
  - run.ceylon

每个文件的内容如下:

designs/BoundedPlane_test.锡兰:

import ceylon.test {
    test
}

shared class BoundedPlane_test() {
    print("BoundedPlane_test class");

    test
    void shouldBeJedi() {
        print("jedi");
        assert(2 == 2);
    }
}

designs/module.锡兰:

native ("jvm")
module designs "1.0.0" {
    import ceylon.test "1.3.3.1";
    shared import ceylon.json "1.3.3";
    shared import gcode "1.0.0";
    import utils "1.0.0";
}

designs/package.锡兰:

shared package designs;

tests/module.锡兰:

native ("jvm")
module tests "1.0.0" {
    import ceylon.test "1.3.3.1";
    import ceylon.math "1.3.3";
    import designs "1.0.0";
}

tests/package.锡兰:

shared package tests;

tests/run.锡兰:

import ceylon.test {
    test, TestRunner, createTestRunner
}
import designs {
    BoundedPlane_test
}

test
Anything myTests1 () {
    // assert something true!
    assert(40 + 2 == 42);
    print("myTests1");
    return null;
}

test
void myTests2 () {
    // assert something false!
    assert(2 + 2 == 54);
    print("myTests2");
}


"Run the module `tests`."
shared void run() {

    print("reached run function");

    TestRunner myTestRunner = createTestRunner(
        [`function myTests1`, `function myTests2`, `class BoundedPlane_test`]);

    print( myTestRunner.run() );
}

这是从 tests/run.ceylon 执行 run 函数的输出:

TEST RESULTS
run:      2
success:  1
failure:  1
error:    0
skipped:  0
aborted:  0
excluded: 0
time:     0s

tests::myTests2 - failure (ceylon.language.AssertionError "Assertion failed
    violated 2 + 2 == 54
        left-hand expression is 4
        right-hand expression is 54")

TESTS FAILED !

一共有三个断言,但只有两个被TestRunner识别。这是来自 tests/run.ceylon 的两个测试。 请注意,BoundedPlane_test.ceylon 中的两个打印语句都没有被打印出来。

当我进行 class 嵌入式测试时它有效 shared :

test
shared void shouldBeJedi() {
    print("jedi");
    assert(2 == 2);
}