Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tpuronen/cppspec
Behavior Driven Development framework for C++
https://github.com/tpuronen/cppspec
Last synced: 3 months ago
JSON representation
Behavior Driven Development framework for C++
- Host: GitHub
- URL: https://github.com/tpuronen/cppspec
- Owner: tpuronen
- License: apache-2.0
- Created: 2009-03-21T09:33:20.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2020-10-06T08:13:45.000Z (about 4 years ago)
- Last Synced: 2024-04-24T20:07:55.379Z (7 months ago)
- Language: C++
- Homepage:
- Size: 195 KB
- Stars: 51
- Watchers: 12
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CppSpec
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 www.behaviour-driven.org.
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(should.be.empty());
specify(not should.be.empty());
specify(context().count(), should.equal(1));
### Exception handlingExceptions are tested by calling a method which should throw an exception and verifying the result. For example:
specify(invoking(&Stack::pop).should.raise.exception());
### Containers
If the context implements iterator interface, you can specify that context should contain either unique items or sequences using contain keyword.
specify(should.contain("key"));
specify(should.contain(sequence.begin(), sequence.end()));### Regular expressions
specify(context().asString(), should.match(pattern));
## Building
Building CppSpec requires CMake and Boost. See CMake documentation for more information about building using CMake.