Questions tagged [cpputest]

CppUTest is a C/C++ based unit xUnit test framework for unit testing and test-driving code.

CppUTest is a C /C++ based unit xUnit test framework for unit testing and for test-driving your code. It is written in C++ but is used in C and C++ projects and frequently used in embedded systems but it works for any C/C++ project.

CppUTest’s core design principles are:

  • Simple in design and simple in use.
  • Portable to old and new platforms.
  • Build with Test-driven Development in mind

CppUTest has support for building mocks. This document described the mocking support. A couple of design goals for the mocking support were:

  • Same design goals as CppuTest – limited C++ set to make it well suitable for embedded soft.
  • No code generation
  • No or very few magic hiding macros
  • Very simple to use
  • The developer stays in control

The main idea is to make manual mocking easier, rather than to make automated mocks. If manual mocking is easier, then it could also be automated in the future, but that isn’t a goal by itself.

Official Website: http://cpputest.github.io/

Useful Links:

98 questions
2
votes
3 answers

Check that a C function is called in a C++ CppUTest

I have an Embedded C/C++ project and I want to write unit tests for it with CppUTest. One simple test that I want to do is to ensure that a particular C function is called during the test. Let's say I have two C functions defined in function.h: void…
Pierre Baret
  • 1,773
  • 2
  • 17
  • 35
2
votes
1 answer

Removing files from lcov tracefile using relative paths

I am attempting to remove certain directories from my lcov tracefile, but am not having any success. I am attempting to use relative paths, and I am using cygwin. My test framework is cpputest. My directory structure looks like this foo_library $…
Nick
  • 1,361
  • 1
  • 14
  • 42
2
votes
2 answers

Unit Test - call a function in two test cases if the function is called only once in productive code

maybe there is someone who has experience with Unit Testing with cpputest. I have something like this: Source code Under Test: main_function() { static int8 is_functioncalled = 1; if (is_functioncalled){ my_local_function(); …
JohnDoe
  • 825
  • 1
  • 13
  • 31
2
votes
1 answer

Mock().enable and disable are not recognized compiling test group project with cpputest lib

I'm trying to compile my test group project but I have no success since the next compiling error that I can not understand in output: Console output: "test_TestHW.c: In member function ‘virtual void TEST_TestHW_TestHW_main_Test::testBody()’: …
Suvi_Eu
  • 255
  • 1
  • 3
  • 16
2
votes
1 answer

Eigen with CPPUTest?

I am having a problem when trying to use CPPUTest to test my library. Everything was fine until i included Eigen library to handle matrix processing. When i tried to build with g++, Eigen library kept throwing…
Cuder
  • 23
  • 4
2
votes
1 answer

Ubuntu 14.04 cpputest examples build fail

I installed cpputest on Ubuntu by: sudo apt-get install cpputest Now I am trying to build the examples from the book and it fails: augre@ubuntu:~/tddec-code$ make make -i -C code make[1]: Entering directory `/home/augre/tddec-code/code' make -f…
augre
  • 330
  • 3
  • 12
2
votes
1 answer

What causes difference in mangled names when compiling on the same compiler (vc12)?

I am currently trying to compile and link the CppUTest library with my project. I use CMake to create a Visual Studio 2013 Solution for the CppUTest-library and it builds. However, when I link the created CppUTest.lib to my application I get an…
Knitschi
  • 2,822
  • 3
  • 32
  • 51
2
votes
1 answer

gcovr doesn't create detailed report when source file located relative in other directories

I'm trying to get proper html output from gcovr when source file is located relative from my root directory. For example (I will mention two cases where gcovr works, and where it has problems): CASE:1 - gcovr works without problems My root directory…
JohnDoe
  • 825
  • 1
  • 13
  • 31
2
votes
0 answers

GDB hangs on breakpoint (using Codeblocks & CppUTest)

I've been using the same CodeBlocks (13.12) with the same GDB (7.5) for the same code-project for over two years now. It's a unit test project using the CppUTest framework (older than 3.4 - I think). The code is constantly changing of course - maybe…
AudioDroid
  • 2,292
  • 2
  • 20
  • 31
2
votes
3 answers

Replacing a define with a "test" define in CppUTest

Is it possible, and if possible how, to replace a certain define with a define which is under control of the test framework? For example, say the embedded system uses a define to access a port like so: #define PORTA_CONFIG (*(volatile unsigned int*)…
Daan Timmer
  • 14,771
  • 6
  • 34
  • 66
2
votes
3 answers

undefined reference to in CppUTest

I have a makefile as described here in the answer: CPPUTestMakeFile Help linking I have in my cpp file: #include "CppUTest/CommandLineTestRunner.h" int main(int ac, const char** av) { /* These checks are here to make sure assertions outside test…
user1876942
  • 1,411
  • 2
  • 20
  • 32
2
votes
1 answer

Why would the address of reset vector differ when two firmwares are linked with the same linker script?

I have a Cortex-M3 chip and on it I am running a bootloader that uses eCos. The bootloader, after checking for firmware updates etc, jumps to another location (BASE_ADDRESS_OF_APP + 0x19) on the ROM where the actual application resides (also…
jayant
  • 2,349
  • 1
  • 19
  • 27
1
vote
0 answers

cpputest: -p doesn't work on this platform, as it is lacking fork

When I pass in the -p option I get the error -p doesn't work on this platform, as it is lacking fork. But then when I add test code for fork() I have no problem #include #include "CppUTest/CommandLineTestRunner.h" #include…
Bob
  • 4,576
  • 7
  • 39
  • 107
1
vote
0 answers

Integrate CPPUTest in Keil

I am a fresher in CPPUTest and I already have a project ready in Keil. Now, I need to test the project in Keil using CPPUTest. Can anyone help me on how to integrate and use CPPUTest on Keil in Windows for already existing project. As I have…
1
vote
1 answer

Can a header with declared functions be mocked?

I'm working in a project targeting a Silicon Labs microcontroller. I want to create a wrapper for the Bluetooth SDK calls. SDK libraries are heavy on dependencies, so by creating a seem in that interface, I can avoid adding them to my tests. Note…
Joel Santos Rico
  • 326
  • 3
  • 17