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
0
votes
1 answer

CppUMock for mocking open() function

Is it possible to mock the C open() function using CppUTest ? #include "CppUTest/CommandLineTestRunner.h" #include "CppUTest/TestHarness.h" #include "CppUTestExt/MockSupport.h" #include extern "C" { #include…
Furlings
  • 71
  • 1
  • 10
0
votes
0 answers

MSVS cpputest: linker: unresolved symbols when trying to build a minimum running example

I want to build a small example project using cpputest under MSVS2019. For this I build a solution with an empty project (will contain my source files later), the included cpputest-repository and my utest-project where I want to write the tests for…
jkbs1337
  • 53
  • 6
0
votes
2 answers

CppUtest example link error

--------------------Configuration: AllTests - Win32 Debug-------------------- Linking... AllTests.obj : error LNK2001: unresolved external symbol "int externTestGroupMockDocumentation" (?externTestGroupMockDocumentation@@3HA) AllTests.obj : error…
0
votes
0 answers

CppUTest - no test is running

i'm trying to setup CppUTest project with CMake. I'm new to CMake so i started with this example: link It works fine. Project compiles and i see tests ran. Then i tried to create my own project based on this example. My project also compiles without…
Mati
  • 1
0
votes
0 answers

How to do a unit test of an external devices register which is read-only?

I am a newbie at TDD and Unit testing and currently reading James Greenings book TDD for Embedded C. I really adopt to use dual targeting because it provides to test my case in both host and target device. I am unit testing my amplifier driver and…
IHK
  • 23
  • 5
0
votes
0 answers

How do I run a mock of a C function in one module, but run the actual implementation in another module while using link time substitution?

I have a scenario where my coworker is writing functions that I wish to use in my module. He wrote the unit tests for his module, and I am writing the unit tests for mine. Naturally I would like to mock his functions for my test. The production code…
0
votes
1 answer

Including cpputest in makefile for project

I want to include cpputest in my project's source tree as a git submodule, but I am not terribly familiar with autotools. I have been looking at this page as a guide I've created the following Makefile, cpputest is in a sub-directory beneath…
Nick
  • 1,361
  • 1
  • 14
  • 42
0
votes
1 answer

Yaml-cpp configuration parser testing with CppUTest issue "expected type-specifier before ‘(’ token"

I am using yaml-cpp library (v 0.6.0) to parse yaml configuration file. Yaml-cpp is installed as system library. I have made a class Parser which checks for key-value pairs in yaml node. The Parser class is built as ConfigParserLibrary static…
vg34
  • 91
  • 2
  • 10
0
votes
0 answers

Connecting CppUTest to C Interface

I'm using CppUTest to handle unit testing with my C library. However, I'm having an issue when compiling the test file. Here's my Makefile (The CPPUTEST_HOME var is an environment variable): CPPFLAGS += -I$(CPPUTEST_HOME)/include CXXFLAGS +=…
S. Sharma
  • 203
  • 1
  • 11
0
votes
0 answers

"Uninteresting mock function call" exception when mocking a function with a template base class

I have a base class A: template class A { public: virtual const std::string& GetName() const = 0; virtual Type GetDefault() const = 0; } And a derived class B: class B : public A { public: const std::string&…
SagiLow
  • 5,721
  • 9
  • 60
  • 115
0
votes
1 answer

CPPUTest multiple defenition of main

Working on getting CPPUTest working with sample application code. I modified couple of make files to get this compiled but now I am facing linker error which states "multiple definition of `main'" This is probably because I have one main in…
Mahesh
  • 1
0
votes
1 answer

Is there a way to build cpputest with pthreads disabled?

I'm planning to use cpputest as a testing framework in my project which I need to cross compile as it will be used on ARM platform. The compiler I'm using for ARM development is arm-gcc which is built with pthreads disabled. Due to this, I need to…
M.K.
  • 1
  • 1
0
votes
2 answers

Mocking/Faking static function within Unit Test Environment

I'm using cpputest to perform Unit Tests of c code. In my source code under test I have a static function which I would like to be "redirected" to a "faked" version of the function when called from the unit test environment. Let's say, I have…
JohnDoe
  • 825
  • 1
  • 13
  • 31
0
votes
1 answer

Faking values within "source file under test" from an unit test file

let's suppose I have a c source file (source file under test) with content: uint8 reg1 = I2CRead(20) uint8 reg2 = I2CRead(24) uint8 reg3 = I2CRead(28) if (reg1 != 0x10) || (reg2 != 0x11) || (reg3 != 0x12) { register content wrong ... } else { …
JohnDoe
  • 825
  • 1
  • 13
  • 31
0
votes
1 answer

CPPUTEST: How to ignore only one mocked call placed between other ones

I would like to ignore one call placed between other ones that I want to call under the same case test. If I use ignoreothercalls I have not clear if the rest of the calls, following this, will be called. I need the rest, after ignored call, will be…
Suvi_Eu
  • 255
  • 1
  • 3
  • 16