Netbeans cunit 测试用例永远不会结束
尝试在 NetBeans 上测试我的 C 项目,测试永远不会结束,而输出为:
Test: testFileOne ...passed Test: testFileTwo ...passed
Run Summary: Type Total Ran Passed Failed Inactive
suites 1 1 n/a 0 0
tests 2 2 2 0 0
asserts 8 8 8 0 n/a
Elapsed time = 0.000 seconds
即使看起来已完成,进度条仍然在值 0.0% 处闪烁。
测试用例都是这样的:
void testMethod() {
CU_ASSERT(1 == 1);
//other lines of code..
CU_ASSERT(0 == 0);
}
每个函数都有多个 CU_ASSERT。 NetBeans 自动生成的测试代码的一些行为。
来自命令行的命令
make test
就像一个魅力,并且没有问题地结束。
以前有人遇到过这个问题吗?有什么办法可以解决这个问题而不困扰我的笔记本电脑?预先感谢您的每一条评论。
Trying to test my C project on NetBeans, the tests never end while the output is:
Test: testFileOne ...passed Test: testFileTwo ...passed
Run Summary: Type Total Ran Passed Failed Inactive
suites 1 1 n/a 0 0
tests 2 2 2 0 0
asserts 8 8 8 0 n/a
Elapsed time = 0.000 seconds
Even if it seems complete, the progress bar is still shining at the value 0.0%.
Test cases are all like:
void testMethod() {
CU_ASSERT(1 == 1);
//other lines of code..
CU_ASSERT(0 == 0);
}
with more than one CU_ASSERT for each function.
Some behaviour with auto-generated test code by NetBeans.
The command
make test
from command line works like a charme and ends with no problem.
Anybody has encountered this issue before? any way to get it solved without strambling my laptop? Thank you in advance for every comment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用调试器(例如 gdb)来跟踪发生的情况。
这将需要将调试标志添加到您的 cunit 代码中。假设您使用的是 gcc,这将是 -g 标志。
使用调试标志进行编译后,您可以简单地使用调试器启动测试二进制文件,就像调试普通程序一样。
You can use a debugger (e.g gdb) to trace what happens.
This will require debugging flags to be added to your cunit code. Assuming you're using gcc, this will be the -g flag.
After compiling with debugging flags you can simply start the test binary with with the debugger, the way you'd debug a normal program.
看来 Netbeans 需要某个指令 a 来停止测试套件,这正是
printf("%%SUITE_FINISHED%% time=0\n");
。您的测试应该如下所示(您可以使用普通的 C 语言或某些库(例如 CUnit)):It seems that Netbeans requires a certain directive a to stop the Test Suite and this is exactly
printf("%%SUITE_FINISHED%% time=0\n");
. Here is how your test should look like (either you are using plain vanilla C or some library like CUnit):