【问题标题】:Boost unit test appears to skip code that should be executed [closed]Boost单元测试似乎跳过了应该执行的代码[关闭]
【发布时间】:2012-11-23 16:38:12
【问题描述】:

似乎下面的 Boost 测试没有像我预期的那样工作。 断点显示BOOST_AUTO_TEST_CASE(...) 内的代码没有运行(但BOOST_AUTO_TEST_CASE(..) 行运行正常)。怎么了?

UT_Math.cpp

#include "../UTest/UT_Math.h"
#include <iostream>

BOOST_AUTO_TEST_CASE(testUTMath)
{
    UTMath test;
    cout << "UTMath is started" << endl;
    test.Test1();
    cout << "Test1 is completed" << endl;
}

UT_Math.h

#include "../Math/Math.h"
#define BOOST_TEST_MODULE UTMathTest
#include <boost/test/unit_test.hpp>

class UTMath 
{
public:
   void Test1()
   {
      BOOST_REQUIRE(1==1);
   }
};

P.S.:应该使用哪些指令在 Normal/UnitTest 模式之间切换(适用于 Windows 和 Unix)?

【问题讨论】:

  • 那为什么测试用例里面的代码没有运行呢?我是否已完成所有要求?据我了解BOOST_AUTO_TEST_CASE 是自动运行的(它不需要特殊的main() func)

标签: c++ unit-testing boost


【解决方案1】:

删除main() 功能已解决问题

【讨论】:

    猜你喜欢
    • 2022-06-10
    • 2017-03-12
    • 1970-01-01
    • 1970-01-01
    • 2021-08-21
    • 1970-01-01
    • 2013-05-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多