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
1
vote
0 answers

Valgrind shows memory leaks in cpputest TEST() macro

It seems that running valgrind when using cpputest library causes memory leaks errors. I use CLion + WSL (GCC + Valgrind). Every line containing TEST() macro is listed in leaks raport. error: Failure in TEST(UT_Iterator, NullCases) Memory…
Mati
  • 753
  • 4
  • 20
1
vote
0 answers

Error in failure indication with unit test plugin(C/C++ Unit) used in eclipse

Error in Red bar display and failure indication in test cases, when used C/C++Unit(Cpputest plugin) with eclipse platform for unit testing. I have downloaded the CppuTest package from the link;"https://github.com/cpputest/cpputest " and i have set…
1
vote
0 answers

CppUTest override header file

I am learning unit testing. I can compile simply programs with Eclipse and CppUTEST. It works. Howover I have problem to understaned how to override/stub headers files. I came up with a test scenario, My files: /src: ---------- src.c src.h //native…
snunit
  • 21
  • 1
  • 4
1
vote
0 answers

Error: register 'sp' unsuitable for global register variables on this target

I am playing around with a project for a STM32 µC. I use the SW4STM32 workbench and CubeMX on a Mac OSX system. My project itself is fine, everything compiles accordingly and behaves on the device as expected. For a further learning purpose, I…
Tobse
  • 37
  • 1
  • 7
1
vote
1 answer

How to use MockSupportPlugin in CppUTest to perform checkExpectations automatically?

CppUTest documentations says MockSupportPlugin makes the work with mocks easier. It does the following work for you automatically: checkExpectations at the end of every test (on global scope, which goes recursive over all scopes) clear all…
andca
  • 33
  • 5
1
vote
0 answers

setting up unit testing arduino code in eclipse

Before retiring, I successfully introduced unit testing in Eclipse for an embedded arm cross compiled target to my team, based on the book Test-Driven Development for Embedded C by James W. Grenning Now I'm wanting to do the same for my own Arduino…
David128
  • 11
  • 2
1
vote
1 answer

Valgrind and QEMU - Unable to detect memory leak

I want to test my C++ code for memory leaks with Valgrind (memcheck) x86. But the software gets cross-compiled and is running on ARM. In order to do some automated testing I decided to emulate my ARM hardware via QEMU. And I also decided to use…
Velocity
  • 21
  • 4
1
vote
1 answer

Windows command line not executing multiple commands

I am building a visual studio project through command line for that I need to run multiple commands at once.So I am created a batch file which includes all the commands.When I run the batch file only first command is executed.My batch file is given…
1
vote
0 answers

Configuration files in separate directory in case of Autotools

I am implementing CPPUTEST for my application along with Autotools, but the final makefile generated in subdirectories is not able to make the final build. Folder Structure: | +- Build_output: holds executable for CPPUTEST +- Configure : holds…
1
vote
1 answer

cpputest on STM8 failed due multiple 'main'

I want to use cpputest on STM8 and installed all the required tools for it. I am able to run cpputest on my simplified code. on my main file which belongs to the hardware I have of course the main function. But in the Test environment I have a main…
K0ertis
  • 121
  • 1
  • 9
1
vote
1 answer

How to inject dependence in Unit testing with cpputest

I'm writing an Unit Test (in cpputest) where I try to perform an "dependence injection" to a function call. This means when the Unit Test have to call the real function which is placed within the file under test, the function call should be…
JohnDoe
  • 825
  • 1
  • 13
  • 31
1
vote
1 answer

How to unit test a state machine in C using mocks of timers function?

I have a function that implements a state machine, test_hw(), i e. First state is idle, and it has not calling any mocked function inside. But this machine has 6 states more. The idea is that machine goes from first state to the last sequently, when…
Suvi_Eu
  • 255
  • 1
  • 3
  • 16
1
vote
1 answer

Cpputest: how to compile and use expectNoCall?

I have wrote the syntax: mock().expectNoCall("productionCode") as Cpputest.org page says. But the compiler says that mocksupport class doesn't support this type of order. test_RFID_Drv.c:322:9: error: ‘class MockSupport’ has no member named…
Suvi_Eu
  • 255
  • 1
  • 3
  • 16
1
vote
2 answers

Is there a way in CppUtest that can call mock and real function at runtime in the same test file?

For example: Production.cpp int func1() { return 7; } void func2() { printf("func2"); } void productionCode() { int x = func1(); if(x==7) func2(); } TestProduction.cpp int func1() { return…
Manie
  • 11
  • 4
1
vote
1 answer

How to mock method returning object using CppUTest

I've following method: QMap DefaultConfig::getConfig() { QMap result; result.insert("Error", LOG_LOCAL0); result.insert("Application", LOG_LOCAL1); result.insert("System", LOG_LOCAL2); …
PaulWebbster
  • 1,480
  • 2
  • 14
  • 27