- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我使用 CPPUnit 编写了一些 C++ 单元测试。
但我不明白如何运行它们。
有没有类似Nunit-gui的工具?
目前我已经在 DLL 中编写并打包了测试。
当我用谷歌搜索时,我发现了这个 http://cppunit.sourceforge.net/doc/lastest/cppunit_cookbook.html
但我无法理解它如何从 DLL 获取测试。
最佳答案
将您的测试用例分组到测试套件中,编写一个 main(),编译,链接到 cppunit 库并从命令行运行可执行文件。
这是一个主要功能的例子:
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
int main( int ac, char **av )
{
//--- Create the event manager and test controller
CPPUNIT_NS::TestResult controller;
//--- Add a listener that colllects test result
CPPUNIT_NS::TestResultCollector result;
controller.addListener( &result );
//--- Add a listener that print dots as test run.
CPPUNIT_NS::BriefTestProgressListener progress;
controller.addListener( &progress );
//--- Add the top suite to the test runner
CPPUNIT_NS::TestRunner runner;
runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
runner.run( controller );
return result.wasSuccessful() ? 0 : 1;
}
如果你真的想要一个 GUI,有 QxRunner .
关于c++ - 如何运行 CPPUnit 单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1077920/
我使用 CppUnit 作为单元测试框架。是否可以选择在运行时执行的测试用例子集? CppUnit 中是否提供了过滤选项来适应这一点? 最佳答案 您可能在 main() 中调用的 TestRunner
我们有许多 CPPUNIT 测试套件,每个测试套件都有自己的 setUp()/tearDown(),我想要做的是在所有套件中都有一个通用的 setUp()/tearDown()。据我了解,对于给定的套
我正在尝试从源代码编译软件。在一个编译阶段,我需要导航包含 CppUnit 库(例如/home/user/lib)和 CppUnit 包含(例如/home/user/include)的目录。如何安装这
我正在移植包含大量基于 CppUnit 1.9.11 左右的测试套件的代码。我的测试运行器可以使用这个(已弃用?)成语打印所有命名的测试套件: cout first (test); if (!s) {
我是第一次尝试使用 CppUnit 测试。当我尝试编译测试代码时,我得到: testing.cpp:(.text+0xca): undefined reference to `CppUnit::Sou
我开始使用 CppUnit 进行 C++ 单元测试。我试图实现的目标是在单个主文件(和函数)上运行我所有的测试套件。让我解释一下: 假设我们有两个类对我设计的两个 C++ 类进行测试: #ifndef
首先,如果我想设置一个测试,我使用什么类: class MyClassTests setup() teardown() testDoingSomething() tes
如何在之后的 CPPUNIT_TEST 中访问我在第一个 CPPUNIT_TEST 中设置的变量? 对于 EX。 CPPUNIT_TEST_SUITE(TestingEx); CPPUNIT_TEST
我想知道测试基类的有效设计或实现。 举个例子: class Polygon; class Rectangle : public Polygon; class Triangle : public Pol
我是CPPUnit测试的新手,已经用各种测试用例编写了登录认证功能的测试。但它只接受返回值零。 如果预期和实际相同,第一个测试用例应返回 1,但它仅在我更改为零时有效。任何建议表示赞赏。谢谢。 voi
我知道可以将 CppUnit Lite 用于嵌入式系统,但 CppUnit 也是这种情况吗? 最佳答案 在 INSTALL 文件中找到答案... If you want to use a cross
我想我在这里遗漏了一些非常愚蠢的东西。 我安装了 libcppunit:(我使用的是 Ubuntu 12.04) $ apt-cache policy libcppunit-dev libcppuni
我使用 CPPUNIT_ASSERT_EQUAL(a, b) 来检查值 a 和 b。 a 和 b 是 unsigned char 类型。因此,当此断言失败时,它将显示预期值和实际值。因为类型是unsi
我在一个测试函数中使用了多个断言,但是当(例如)第一个断言失败时,其余的断言将不再执行。有没有办法用 CppUnit 做一个断言(CPPUNIT_ASSERT),它在失败后不会离开测试函数?例如非中止
考虑这个 CPPUNIT 测试类打算进行相同的测试 ( doTest ) 但具有不同的参数: class MyTest : public CPPUNIT_NS::TestFixture { CPP
好吧,我基本上是想着手编写一些 CPPUnit 测试,但我不知道该怎么做。这里我有一些代码,基本上是为关联的按钮组和位置参数获取指向菜单按钮的指针,我将如何为此创建测试? CMenuButton* C
我对 C++ 和 CPPUnit 有点陌生。有人能告诉我应该使用什么来断言数组值(将它们与预期进行比较)。我应该使用 memcmp 还是在 CPPUnit、一般的 C++ 或任何其他库中有更好的东西?
我知道 CppUnit 可以通过以下方式测试异常: CPPUNIT_ASSERT_THROW(expression, ExceptionType); 谁能解释一下 CPPUNIT_ASSERT_THR
我正在使用 CppUnit 为 C++ 库编写单元测试。默认情况下,它会打印一个“.”。字符到每个测试的控制台。在测试运行之前,我想在单独的行上记录每个测试的名称。 我已经研究了 CppUnit AP
我正在使用 CMake 开发一个项目,并且刚刚集成了一些 CppUnit 测试。我想使用 CTest,因此我在 CMakeLists.txt 文件中使用了 add_test,以便在键入 make te
我是一名优秀的程序员,十分优秀!