简体   繁体   English

在Visual Studio 2012中提升单元测试引发异常

[英]Boost unit tests throwing exceptions in Visual Studio 2012

I recently upgraded my laptop to Windows 8 so that I can develop for W8 and WP8. 我最近将笔记本电脑升级到Windows 8,以便可以为W8和WP8开发。 I had some projects that were created with Visual Studio 2010 that used Boost.Test for unit testing. 我有一些使用Visual Studio 2010创建的项目,这些项目使用Boost.Test进行单元测试。 I tried converting the projects to VS2012 projects, but ran into problems, so I just created fresh VS2012 projects using the same source code as before. 我尝试将项目转换为VS2012项目,但遇到了问题,因此我只是使用与以前相同的源代码创建了新的VS2012项目。 However, every unit test suite throws an exception when I run it. 但是,每个单元测试套件在运行时都会引发异常。 I've debugged it and found that it's throwing the exception when it tries to make the report in the make_report method in results_reporter.ipp . 我已经调试它,发现它抛出异常时,它试图让在报告make_report的方法results_reporter.ipp The offending line is 冒犯的行是

case CONFIRMATION_REPORT:
    s_rr_impl().m_formatter->do_confirmation_report( framework::get<test_unit>( id ), *s_rr_impl().m_output );

Somewhere in the code there is a map object which has some bad memory, and hence the exception. 代码中的某个地方有一个map对象,它的内存不好,因此也有异常。 I'm using Boost 1.50.0. 我正在使用Boost 1.50.0。 I've also tried the most recent release, 1.52.0, but with the same results. 我还尝试了最新版本1.52.0,但结果相同。 Is VS2012 buggy, or is there some setting/configuration that I'm unaware of, or differences in developing on Windows 7 vs. 8? 是VS2012越野车,还是我不知道的某些设置/配置,还是在Windows 7 vs. 8上进行开发时存在差异?

Edit 编辑

Here is an example test that throws an exception in my environment with VS2012 and Boost 1.50.0: 这是一个示例测试,该示例在我的环境中使用VS2012和Boost 1.50.0引发异常:

#define BOOST_TEST_MODULE exception.test
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(SuiteTest)

BOOST_AUTO_TEST_CASE(exceptionTest){
    BOOST_REQUIRE(true);
}

BOOST_AUTO_TEST_SUITE_END()

之所以发生这种情况,是因为我的项目中的另一个测试类无意中导入了newdelete的某些全局替代。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM