cppunit

CUnit - 'Mocking' libc functions

非 Y 不嫁゛ 提交于 2019-12-05 16:21:29
I'm using CUnit for my project unit testing. I need to test whether I call libc functions with the right parameters & whether I treat their return values the right way. for example: if I call the bind(...) function - I would like to check which af param I pass & assert if this is the wrong one, and also I would like to emulate it's return value & assert if I check it the right way. For these purposes I would expect the CUnit environment to have a built-in mechanism to let me call a 'mocked' bind() function while testing and a real bind() function when running the code - but I can't find

Test Driven Development with C++

青春壹個敷衍的年華 提交于 2019-12-03 03:47:08
问题 Looking to start doing TDD in C++. I've seen CPPUnit, but I was wondering if there are other options that people prefer? Thanks for your suggestions! 回答1: I can recommend Google Mock. It comes with a copy of Google Test bundled. We switched from UnitTest++ too Google Test/Google Mock a couple of years ago and have never looked back. Google Mock can be used even if you don't want to use the mocking facilities. Its matchers are very useful. 回答2: I switched from CppUnit to boost::test some years

Test Driven Development with C++

怎甘沉沦 提交于 2019-12-02 17:12:55
Looking to start doing TDD in C++. I've seen CPPUnit, but I was wondering if there are other options that people prefer? Thanks for your suggestions! Tobias Furuholm I can recommend Google Mock . It comes with a copy of Google Test bundled. We switched from UnitTest++ too Google Test/Google Mock a couple of years ago and have never looked back. Google Mock can be used even if you don't want to use the mocking facilities. Its matchers are very useful . I switched from CppUnit to boost::test some years ago and I'm much happier with it. Documentation for CppUnit is nonexistent. Good luck trying

How to run subset of unit tests in CPPUnit by selecting them at run-time?

这一生的挚爱 提交于 2019-12-01 05:14:19
I am using CppUnit as a unit test framework. Is it possible to select a subset of testcases to execute at runtime? Is there a filtering option provided within CppUnit to accomodate this? The TestRunner::run() method you are likely calling in your main() actually has optional parameters: run(std::string testName = "", bool doWait = false, bool doPrintResult = true, bool doPrintProgress = true). testName must be the specific name of a test. You could request a specific test by name if you wanted. You can also call runTest(Test*) on a specific test, or runTestByName(testName). But it sounds like

How to run subset of unit tests in CPPUnit by selecting them at run-time?

北慕城南 提交于 2019-12-01 02:25:45
问题 I am using CppUnit as a unit test framework. Is it possible to select a subset of testcases to execute at runtime? Is there a filtering option provided within CppUnit to accomodate this? 回答1: The TestRunner::run() method you are likely calling in your main() actually has optional parameters: run(std::string testName = "", bool doWait = false, bool doPrintResult = true, bool doPrintProgress = true). testName must be the specific name of a test. You could request a specific test by name if you

Parameterizing a test using CppUnit

混江龙づ霸主 提交于 2019-11-30 19:53:30
My organization is using CppUnit and I am trying to run the same test using different parameters. Running a loop inside the test is not a good option as any failure will abort the test. I have looked at TestDecorator and TestCaller but neither seems to really fit. Code samples would be helpful. It does not appear possible in CppUnit to parameterize a test case directly (see here and here ). However, you do have a few options: Use a RepeatedTest You may be able to make some clever use of the built-in RepeatedTest decorator. This allows a test case to be run multiple times (though without

How can I measure CppUnit test coverage (on win32 and Unix)?

半腔热情 提交于 2019-11-29 23:05:37
I have a very large code base that contains extensive unit tests (using CppUnit). I need to work out what percentage of the code is exercised by these tests , and (ideally) generate some sort of report that tells me on a per-library or per-file basis, how much of the code was exercised. Here's the kicker: this has to run completely unnatended (eventually inside a continuous integration build), and has to be cross platform (well, WIN32 and *nix at least). Can anyone suggest a tool, or set of tools that can help me do this? I can't change away from CppUnit (nor would I want to - it kicks ass),

Ubuntu13.10下Cppunit1.12.1安装记录

╄→гoц情女王★ 提交于 2019-11-29 12:35:13
环境介绍 ubuntu version: 13.10 gcc, g++ version: 4.8.1 cppunit version: 1.12.1 cppunit 可以在该处下载 cppunit传送门 安装过程 解压以后, 安装仍然是传统的三步骤: ./configure make sudo make install configure 的过程能够很容易的通过, 当进行make的时候, 则出现了如下的错误: g++ -g -O2 -o .libs/DllPlugInTester DllPlugInTester.o CommandLineParser.o -ldl ../../src/cppunit/.libs/libcppunit.so -lm ../../src/cppunit/.libs/libcppunit.so: undefined reference to `dlsym' ../../src/cppunit/.libs/libcppunit.so: undefined reference to `dlopen' ../../src/cppunit/.libs/libcppunit.so: undefined reference to `dlclose' collect2: error: ld returned 1 exit status make[2]: ***

How can I measure CppUnit test coverage (on win32 and Unix)?

旧街凉风 提交于 2019-11-28 20:14:10
问题 I have a very large code base that contains extensive unit tests (using CppUnit). I need to work out what percentage of the code is exercised by these tests , and (ideally) generate some sort of report that tells me on a per-library or per-file basis, how much of the code was exercised. Here's the kicker: this has to run completely unnatended (eventually inside a continuous integration build), and has to be cross platform (well, WIN32 and *nix at least). Can anyone suggest a tool, or set of

CppUnit源码解析

放肆的年华 提交于 2019-11-28 09:49:45
前言   CppUnit是一个开源的单元测试框架,支持Linux和Windows操作系统,在linux上可以直接进行源码编译,得到动态库和静态库,直接链接就可以正常使用,在Windows上可以使用VC直接进行编译,非常便于调试。CppUnit的源码框架被运用到了Java和Python等语言中,使用非常广泛,熟悉了一种语言下的CppUnit使用方法,其他语言测试框架也不在话下,本文以cppunit-1.12.1为例进行演示和说明。 一个例子 Linux下CppUnit源码编译和安装 解压源码文件到cppunit-1.12.1目录 cd cppunit-1.12.1 ./configure --prefix=安装路径(必须是绝对路径) make make install 编辑测试代码 一共三个文件main.cpp、simpleTest.h、simpleTest.c,目录下文件的组织结构如下所示: 三个文件的源码如下: //main.cpp文件 #include "cppunit/TestResultCollector.h" #include "cppunit/TextOutputter.h" #include "cppunit/XmlOutputter.h" #include "cppunit/CompilerOutputter.h" #include "cppunit