当使用 boost 库进行测试时出现访问冲突时,我不想停止测试
当使用 boost 测试库进行单元测试时发生访问冲突。
然后,测试中止并完成。
但是,我不想停止单元测试。只是我想获得例外或通知。
我该怎么办?
谢谢,请理解我的傻瓜英语(8(|)
编辑!
访问冲突错误不在测试程序中。它在目标程序(被测试)中。
例如。
目标程序
int target_function()
{
char *source;
strcpy(source, "access violation");
return 0;
}
测试程序
BOOST_AUTO_TEST_CASE(access_violation)
{
target_function();
BOOST_CHECK(false);
}
编辑!!!
我使用视觉windows系统中的studio 2005和linux系统中的g++也可以
编辑! 我理解你的意见。但是,我不是目标程序程序员。所以,我无法修复它们。 我只想继续我的测试计划。我做了很多测试用例。所以。每当我的测试程序遇到任何错误时,请传递该错误并继续。
When occur to access violation in unit test with boost test library.
and then, test was aborted, and finished.
But, I don't want to stop the unit test. Just I want to get exception or notification.
How do I?
Thank you, and please understad my fool english (8(|)
EDIT!
Access violation error is not in test program. It is in the target program(be tested).
for example.
target program
int target_function()
{
char *source;
strcpy(source, "access violation");
return 0;
}
test program
BOOST_AUTO_TEST_CASE(access_violation)
{
target_function();
BOOST_CHECK(false);
}
EDIT!!!
I use visual studio 2005 in windows system and g++ in linux system, too.
EDIT!!!
I understood your opinion. But, I am not target program programer. So, I can't fix them.
I just want to continue my test program. I make a lot of test case. So. whenever my test program meet the any error, pass that error and go on.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当发生访问冲突时,整个过程的完整性就会受到损害。没有明智的方法可以从这种情况中恢复过来。因此没有明智的方法来继续测试。当进程自身损坏时,无论单元测试框架是否愿意,进程都会停止运行。
When you have an access violation, the integrity of the process as a whole is compromised. There's no sane way to recover from this condition; and therefore no sane way to continue testing. When the process corrupts itself, the process is going down, whether the unit test framework would like it to or not.
我相信用于尝试捕获访问违规的方法是实现定义的。然而,无论如何,这都是一个坏主意。如果您的程序崩溃并烧毁,您也可以中止测试过程并在继续之前修复问题。
I believe methods used to attempt to catch access violations are implementation defined. However, this is a bad idea any way you cut it. If your program is crashing and burning, you might as well abort the testing process anyway and just fix the problem before continuing.