Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test Driven Development with C++

Tags:

Looking to start doing TDD in C++. I've seen CPPUnit, but I was wondering if there are other options that people prefer?

Thanks for your suggestions!

like image 318
hahuang65 Avatar asked Mar 15 '11 04:03

hahuang65


People also ask

What is TDD and CI?

Continuous integration implies that you build your system whenever it changes. You may choose to run your test suite at that point, which is a good idea, but you're not required to. With Test Driven Development (TDD) you combine both a test-first development (TFD) approach and refactoring.

What are the 3 steps of test-driven development?

Red, Green and Refactor is the three phase of Test Driven Development and this the sequence that get followed while writing code. When followed, this order of steps helps ensure that you have tests for the code you are writing and you are writing only the code that you have to test for.

How is unit testing implemented in C?

Define the function within the unit test file itself, probably at the top of the file. If it is a C function being called by C code, place it within the extern "C" {} section. As a last resort, one can compile out the function calls and implementations using a define for unit tests. e.g. #if !

Which tool is used for TDD?

csUnit and NUnit – Both are open source unit testing frameworks for . NET projects. PyUnit and DocTest: Popular Unit testing framework for Python. TestNG: Another popular Java testing framework.


1 Answers

I can recommend Google Mock, which has become part of Google Test bundled. We switched from UnitTest++ to Google Test/Google Mock a couple of years ago and have never looked back.

Google Mock can be used even if you don't want to use the mocking facilities. Its matchers are very useful.

like image 92
Tobias Furuholm Avatar answered Oct 02 '22 19:10

Tobias Furuholm