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
2 answers

CppUTest not running on target - How to "fake" register

I'm doing Unit Testing of embedded C code without running on target hardware.Here is one part of the code: uint8 tempReadback = 0; write_to_i2c( msg->addres, msg->value ); tempReadback = read_from_i2c( msg->addres); if( tempReadback ==…
JohnDoe
  • 825
  • 1
  • 13
  • 31
1
vote
1 answer

Compiling latest release of CppUTest (3.7) with MinGw, pthreads missing

I'm trying to use CppUTest in Windows, first step is to get it to work and I already have problems. These are the things I've tried: First Approach With CMake, using the cmake GUI I can do the configure and generate command and I get something in…
Mite
  • 57
  • 1
  • 9
1
vote
1 answer

tdd using cpputest make errors in ubuntu 14.04

I am trying to learn cpputest, so went to the cpputest manual and copied the below code in my ubuntu 14.04lts laptop, and tried to make. I am new to make files, and I got a bunch of errors - how can I correct my code? #include…
pradeep
  • 31
  • 3
1
vote
2 answers

How to compile CppUTest in cygwin?

I've taken over a programming project from another programmer. This project uses a lot of unit tests to verify the code which I intend to continue using. I have no prior experience with unit testing (apart from some theoretical knowledge) so he…
Jesper Evertsson
  • 613
  • 9
  • 28
1
vote
1 answer

CppUTest example doesn't work

I just installed CppUTest on my MAC using brew as indicated by the guide. It failed when I tried to build the example cpp. TEST_GROUP(FirstTestGroup) { }; TEST(FirstTestGroup, FirstTest) { FAIL("Fail me!"); } I guess it is because the header…
chen ming
  • 37
  • 4
1
vote
1 answer

Generate Unit Tests from a scenario table where inputs and expected results are specified

I'm currently trying to generate some post coding UT for a module. The module classifies input data to a DB, if a match is found, a proper value is returned. After building a table with all possible input scenarios and their expected results, I…
EdwardH
  • 1,523
  • 2
  • 12
  • 20
1
vote
1 answer

libstdc++-6.dll error while running CPPUTest

I'm trying to learn TDD using CPPUTest for embedded C unit testing. I was able to compile a basic C code using gcc on eclipse CDT. I was trying to compile the c++ files that come with CPPUTest. The machine I'm trying to run is 64-bit Windows 7 OS. I…
raman
  • 61
  • 3
0
votes
2 answers

CPPUTest debugging - C++

I am learning TDD and using CppUTest in eclipse. Is there any way to debug my code getting a nagging segmentation fault. Thanks
Saaras
  • 379
  • 5
  • 17
0
votes
1 answer

cpputest/valgrind - memory leak indicator inconsistent

I'm forced to use cpputest and I want to know if its memory leak detector is useful. As of now, it seems to be garbage. main.cpp: #include #include "CppUTest/CommandLineTestRunner.h" int main(int argc, char** argv) { int ret = 0; …
Bob
  • 4,576
  • 7
  • 39
  • 107
0
votes
0 answers

cpputest mock EXPECTED calls that WERE NOT fulfilled

I'm trying to test some cpp code with cpputest. There is the code I would test: void TA_MotRunng(rte_MotRunng_t_iArgs_t *args) { MotRunngLocalVariables_t lv; InpGetAndChk(args, &lv); std::cout << "lv.ip.drvEna_HW = " << lv.ip.drvEna_HW <<…
0
votes
0 answers

CPPUTest Mock getting data pointer data for testing?

I have a mock for a c function int Eeprom_WriteBuffer(uint32_t address, uint8_t *data, uint16_t data_len) { return mock("eeprom").actualCall("Eeprom_WriteBuffer") .withParameter("address", address) …
Grant Dare
  • 23
  • 5
0
votes
1 answer

Debugging (breakpoints / etc) in VSCode with different makefiles for parts of the codebase

I'm working on an ESP-IDF based project that runs on ESP32 microcontrollers. The project has a bunch of different C++ libraries (ESP-IDF calls them components) I've written. Normally I compile the whole project and it gets installed on the ESP32,…
chrispitzer
  • 991
  • 1
  • 8
  • 26
0
votes
0 answers

Make error with CppUTest - libCppUTest.a error adding symbols

I am trying to create a project folder structure based on CMake, using the gcc-arm-none-eabi toolchain, and that can use QEMU (arm) to run CppUTest. Right now, my folder structure look like this: project/ ├── app/ │ ├── src/ │ │ └── main.cpp │…
mmnano50
  • 37
  • 6
0
votes
0 answers

How to mock a class with non virtual function with CppUMock

I'm writing unit tests with CppUTest & CppUMock framework. Here is a example of what I have : class ClassA { public: ClassA(ClassB &classB); } class ClassB { public: ClassB(); void DoingThings(void); } I want to unit test ClassA. The…
LPo
  • 45
  • 4
0
votes
0 answers

Unit test for a function in a function using CppUTeset

How a unit test can be made for this kind of structure? How to change the call so function a() will call function mock_b() instead of function b(). // source.h int b(int x); bool a(); // source.cpp int b(int x){return x;} bool a(){return (b(5) >…
Ronen333
  • 69
  • 1
  • 8