测试设置错误:测试树为空 [英] Test setup error: test tree is empty

查看:88
本文介绍了测试设置错误:测试树为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建空的 boost 测试项目,但出现此错误.

I am trying to build empty boost test project, but i got this error.

测试设置错误:测试树为空

Test setup error: test tree is empty

我正在使用 QT Creator.这意味着什么?在 boost 测试教程中:http://www.boost.org/doc/libs/1_53_0/libs/test/doc/html/tutorials/new-year-resolution.html 当您运行空项目时,您会得到:

I am using QT Creator. What does that mean? In boost testing tutorial: http://www.boost.org/doc/libs/1_53_0/libs/test/doc/html/tutorials/new-year-resolution.html when you run empty project you get:

*** 未检测到错误

我的代码:main.cpp

My code: main.cpp

#include <iostream>

#define BOOST_TEST_DYN_LINK
#include <mepobject_test.h>

mepobject_test.h

mepobject_test.h

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

// EOF

*pro 文件

TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG += qt
LIBS += -L"/usr/lib/x86_64-linux-gnu" -lboost_unit_test_framework -lboost_system

SOURCES += main.cpp

HEADERS += \
    mepobject_test.h

推荐答案

与静态库链接(或使用仅标头版本).此外,如果您计划使用自动测试用例注册,最好将 BOOST_TEST_MODULE 移动到您的 main.cpp 文件以确保它满足 BOOST_TEST_MAIN 要求,因为它会创建一个入口点到您的测试二进制文件.

Link with the static library (or use the header-only version). Also, if you plan on using automatic test case registration, better move BOOST_TEST_MODULE to your main.cpp file to ensure it satisfies BOOST_TEST_MAIN requirements, because it creates an entry point to your test binary.

在您的情况下,BOOST_TEST_MODULE 创建的入口点与动态库中使用的入口点之间的差异可能是导致问题的原因.

In your case, likely, the difference between the entry point created by BOOST_TEST_MODULE and the one used in the dynamic library is what causing the issue.

参见 http://boost.2283326.n4.nabble.com/Test-tree-is-empty-tp2580070p2580071.html

这篇关于测试设置错误:测试树为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆