14得票6回答
如何使用UnitTest++从测试中访问私有类字段?

在使用UnitTest++编写单元测试时,我面临一个麻烦。我想知道如何以一种干净的方式(或者任何一种方式...)访问私有成员类字段。 到目前为止,我已经有了一个解决方案来访问受保护成员,即使用从被测试类派生的类夹具(fixture)。以下代码展示了这个想法:struct MyFixture ...

12得票6回答
如何使用UnitTest++运行单个测试?

我该如何使用 UnitTest++ 运行单个测试? 我正在使用默认配置的 UnitTest++ 进行测试。我的 main 函数如下:int main() { printf("diamond test v0.1 %s\n\n",TIMESTAMP); diamond::startu...

12得票1回答
我该如何告诉 lcov 去哪里找我的 .cpp 和 .h 文件?

我的源代码和构建目录如下(参见Makefile to put object files from source files different directories into a single, separate directory?),经过make编译和运行FooAndBarTests之后...

8得票2回答
开始使用UnitTest++

这是我从他们的基本示例中获得的当前代码:http://unittest-cpp.sourceforge.net/UnitTest++.html。 #include <unittest++/UnitTest++.h> TEST(FailSpectacularly) { C...