Behavior Driven Development framework for C++
C++ C Shell
Switch branches/tags
Nothing to show
Latest commit 7293860 Aug 21, 2013 @tpuronen Merge pull request #9 from meshell/SpecDoxReporter
Support for test method names with underscore instead of camelcase.


CppSpec is a behavior driven development (BDD) framework for C++. BDD is a refinement of TDD which turns the focus from writing the tests to the process of defining the behavior of the software using tests. You can read more about BDD from

CppSpec is licensed under Apache License, version 2.0.

Using CppSpec

To define behavior of your class you need to create a specifications for different states of your class. Specification is created by deriving from CppSpec::Specification class. Expectations for the behavior are written using specify method.

Basic validation

specify(context().count(), should.equal(1));  

Exception handling

Exceptions are tested by calling a method which should throw an exception and verifying the result. For example:



If the context implements iterator interface, you can specify that context should contain either unique items or sequences using contain keyword.

specify(should.contain(sequence.begin(), sequence.end()));

Regular expressions

specify(context().asString(), should.match(pattern)); 


Building CppSpec requires CMake and Boost. See CMake documentation for more information about building using CMake.