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
32
votes
7 answers

Undefined reference to operator new

I'm trying to build a simple unit test executable, using cpputest. I've built the cpputest framework into a static library, and am now trying to link that into an executable. However, I'm tied into a fairly complicated Makefile setup, because of…
mbyrne215
  • 2,304
  • 4
  • 21
  • 16
8
votes
1 answer

gcc/linux: CppuTest shows memory leak using static vectors, false positive?

in xxxx.h file: struct dn_instance_pair { std::string theDn; int theInstance; }; typedef struct dn_instance_pair t_dn_inst_pair; struct table_rowid_type { char theTable[101]; sqlite3_int64 theRowid; int operation; }; // static…
Esko Hujanen
  • 83
  • 1
  • 3
6
votes
1 answer

CppUTest Unit Testing Framework Multiple Definition Exception

I will try to make this a purely minimal example to be as applicable to as many people as possible as well as protect any sort of code sharing that might violate an NDA. Hope this is okay! I am using CppUTest and CppUMock (compiling with gcc/g++ and…
Jeffrey
  • 63
  • 6
6
votes
0 answers

CppUTest error with -std=c++11 on g++ 4.7.2

I've been using CppUTest with g++ 4.7.2 for a while now without problems. However, I've just flipped the -std=c++11 option on so I can start using std::unique_ptr and it fails immediately. Even just compiling the main module: #include…
Crowman
  • 25,242
  • 5
  • 48
  • 56
4
votes
1 answer

CppUtest: how to return a custom struct from mocked function

I'm starting using CppUTest for some C embedded projects. Now I'm dealing with mocked calls to the system. After learned how to pass C typicall types, in ex: Example that works properly: Mock file part of code: uint32_t…
Suvi_Eu
  • 255
  • 1
  • 3
  • 16
3
votes
2 answers

Why do I get 'multiple definition' errors when linking against an archive?

I'm using CppUTest to test the C code defined in a fornol.c source file. That file defines the main production main() function. I also have an AllTests.cpp file that also has a main() function, but that main() is supposed to be used only when…
lindelof
  • 34,556
  • 31
  • 99
  • 140
3
votes
1 answer

How to add compile options to a CMake FetchContent-dependency?

I have a C/C++ project in which I want to use CppUTest. So I include the dependency of CppUTest with: include(FetchContent) FetchContent_Declare( CppUTest GIT_REPOSITORY https://github.com/cpputest/cpputest.git GIT_TAG …
Stefan
  • 150
  • 1
  • 10
3
votes
1 answer

CppuTest to build with C++11 versions

Installed g++ 4.9.0 (experimental) version under Ubuntu (I am using certain features provided by this version) When building my code, I use cmake from a script, and it builds correctly. gcc below contains the path where g++ is installed…
3
votes
2 answers

How to add a static library CppUTests to my project atmel studio

I'm using Atmel Studio 6.1.2 SP2. I'm setting up CppUTest for our embedded system project. I created a static CPP library for the CppUTest Framework which copiled successfuly after a small change. Now I'm including this library to a test project. A…
Snake Sanders
  • 2,641
  • 2
  • 31
  • 42
3
votes
1 answer

cpputest error message allocation/deallocation

I am receiving this error message when using cppunit to test my application Allocation/deallocation type mismatch allocated at file: line: 0 size: 262144 type: new [] deallocated at file: line: 0 type: delete I have already…
Justin Wood
  • 9,941
  • 2
  • 33
  • 46
3
votes
2 answers

CppUTest: how to pass more data to a specific mock call?

I'm starting using CppUTest for some C/C++ projects. Especially the mocking extension sound good, but I'm currently struggling how to set up mocks in the right way. Assume a low level class for abstracting network socket communication. My first…
Andi
  • 888
  • 2
  • 10
  • 24
2
votes
1 answer

CppUTest examples build fails

I am new to mac! I download the xcode4.2 and tried to build CppUTest-v3 1)when I do make, I have the following logs compiling AllTests.cpp compiling AllocationInCppFile.cpp compiling CheatSheetTest.cpp compiling…
Adjeiinfo
  • 159
  • 1
  • 2
  • 15
2
votes
2 answers

Unit testing C module static variable

I have a C module and I want to refactor a little bit. There are some global variables and structures which are not hidden (in the module.h file). I use this variables in some test case but nowhere else so I thought it's a good idea to set them to…
hcpeter
  • 614
  • 3
  • 11
  • 24
2
votes
1 answer

Compiling cpputest with mingw-w64

I'm trying to compile cpputest with mingw-w64 but can't make it work and I can't find any resources on how to do that. So hopefully this question will help others in the future. I would like to compile cpputest using mingw-w64, preferably without…
Leonardo
  • 1,533
  • 17
  • 28
2
votes
1 answer

Compilation error after including jsoncpp

When I try to build test sources I get an error like after this. stl_tree.h:542:14: error: ‘__node’ does not name a type ::new(__node) _Rb_tree_node<_Val>; Executor's content. #include #include…
nurisezgin
  • 1,530
  • 12
  • 19
1
2 3 4 5 6 7