我目前有一个TestRunner(来自ceylon.test),可以从本地函数进行测试。现在,我试图使其发现嵌入在单独文件中编写的类中的测试。但是,TestRunner在类中找不到测试,而且我不知道如何调试它。没有编译器错误。如何开始调试此问题?
这是相关文件的文件+文件夹结构:
source/
- designs/
- BoundedPlane_test.ceylon
- module.ceylon
- package.ceylon
- tests/
- module.ceylon
- package.ceylon
- run.ceylon
这是每个文件的内容:
designs / BoundedPlane_test.ceylon:
import ceylon.test {
test
}
shared class BoundedPlane_test() {
print("BoundedPlane_test class");
test
void shouldBeJedi() {
print("jedi");
assert(2 == 2);
}
}
designs / module.ceylon:
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.ceylon:
shared package designs;
tests / module.ceylon:
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";
}
测试/package.ceylon:
shared package tests;
测试/运行Ceylon:
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的所有打印语句均未打印。
答案 0 :(得分:0)
当我进行类嵌入式测试shared
时有效:
test
shared void shouldBeJedi() {
print("jedi");
assert(2 == 2);
}