我想开始使用升压测试库为我的应用程序创建测试。使用升压单元测试的问题
继我在http://www.boost.org/doc/libs/1_47_0/libs/test/doc/html/tutorials/new-year-resolution.html找到的教程之后,我开始了我的测试课程。
所以,我创建了一个类为我的测试,以及简单的.cpp这是一个
#define BOOST_TEST_MODULE MyClass test
#include <boost/test/unit_test.hpp>
#include "myclasstest.h"
MyClassTest::MyClassTest()
{
}
/**
* Test the class.
*/
bool MyClassTest::testClass()
{
BOOST_AUTO_TEST_CASE(empty_test)
{
MyClass xTest;
BOOST_CHECK(xTest.isEmpty());
}
return true;
}
好吧,我知道我必须做的东西比返回true更聪明,但它不问题。问题是它不能编译。 我认为该库已更正加载,因为如果我只用前两行进行编译,我没有错误,如教程页面中所述。
如果我尝试编译它,我从GCC获得此错误输出:
myclasstest.cpp: In member function ‘bool MyClassTest::testClass()’:
myclasstest.cpp:16:5: error: a function-definition is not allowed here before ‘{’ token
myclasstest.cpp:16:1: error: ‘empty_test_invoker’ was not declared in this scope
myclasstest.cpp:16:5: error: template argument for ‘template<class T> struct boost::unit_test::ut_detail::auto_tc_exp_fail’ uses local type ‘MyClassTest::testClass()::empty_test_id’
myclasstest.cpp:16:5: error: trying to instantiate ‘template<class T> struct boost::unit_test::ut_detail::auto_tc_exp_fail’
myclasstest.cpp:17:5: error: a function-definition is not allowed here before ‘{’ token
myclasstest.cpp:23:1: error: expected ‘}’ at end of input
myclasstest.cpp:23:1: warning: no return statement in function returning non-void
我新的刺激,所以我不知道我必须做的。我做错了什么?我认为我已经完成了相同的教程步骤,或者不是?
感谢您的回复。