如何使用 cppunit 显示测试方法名称
如何从点更改 cppunit 的输出,指示对测试的实际名称进行了多少次测试,或者至少是提供给测试调用者的字符串,如计算点并猜测哪个测试-它所代表的函数是非常低效的,如果出现分段错误,实际上会杀死整个程序。我确实只是找到了在断言失败的情况下更改错误输出的参考,但在一般输出上没有任何内容。
我的 Testclass 的套件函数:
static CppUnit::Test *suite() {
CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "Map Parser" );
//string to state
suiteOfTests->addTest( new CppUnit::TestCaller<Parser_test>("string to state I",&Parser_test::test_string_to_state_I));
....
return suiteOfTests;
}
Main.cpp
CppUnit::TextUi::TestRunner runner;
runner.addTest( Parser_test::suite() );
runner.run();
我希望有一些像这样的输出:
string to state I : OK
string to state II : OK
...
这样我就能够确定程序何时由于不可捕获的异常(如 SegFault)而崩溃。
但目前我的输出看起来像这样:
...........
Segmentation fault
How do I change the output of cppunit from dots, indicating how many tests are done to the actual names of the tests, or maybe just at least the string which was given to the test-caller, as counting the dots and guessing which test-function it represents is quite unproductive, in case of an Segmentation Fault which actually kills the whole program. I did just find reference for changing the error-output in case of a failed assert, but nothing on the general output.
The suite function of my Testclass:
static CppUnit::Test *suite() {
CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "Map Parser" );
//string to state
suiteOfTests->addTest( new CppUnit::TestCaller<Parser_test>("string to state I",&Parser_test::test_string_to_state_I));
....
return suiteOfTests;
}
Main.cpp
CppUnit::TextUi::TestRunner runner;
runner.addTest( Parser_test::suite() );
runner.run();
I would love to have some output like this:
string to state I : OK
string to state II : OK
...
as then I am able to determine when the program crashed due to a non-catchable exception, like a SegFault.
But at the moment my ouptut looks like this:
...........
Segmentation fault
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
BriefTestProgressListener 完成以下工作:
A BriefTestProgressListener does the job:
您需要使用
CppUnit::XmlOutputter
。我不确定连接它的确切语法。You'll want to utilize
CppUnit::XmlOutputter
. I'm not certain on the exact syntax to hook this up.