zonasw / doctest

The fastest feature-rich C++98/C++11 single-header testing framework for unit tests and TDD

Home Page:http://bit.ly/1rsQ0Br

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The fastest feature-rich C++98/C++11 single-header testing framework for unit tests and TDD

master branch Linux/OSX Windows
dev branch Linux/OSX Windows

doctest is a new C++ testing framework but is by far the fastest both in compile times (by orders of magnitude) and runtime compared to other feature-rich alternatives. It brings the ability of compiled languages such as D / Rust / Nim to have tests written directly in the production code by providing a fast, transparent and flexible test runner with a clean interface.

The framework is and will stay free but needs your support to sustain its development. There are lots of new features and maintenance to do. If you work for a company using doctest or have the means to do so, please consider financial support. Monthly donations via Patreon and one-offs via PayPal.

A complete example with a self-registering test that compiles to an executable looks like this:

cover-example

There are many C++ testing frameworks - Catch, Boost.Test, UnitTest++, cpputest, googletest and many other.

The key differences between it and other testing frameworks are that it is light and unintrusive:

  • Ultra light on compile times both in terms of including the header and writing thousands of asserts
  • Doesn't produce any warnings even on the most aggressive warning levels for MSVC/GCC/Clang
  • Offers a way to remove everything testing-related from the binary with the DOCTEST_CONFIG_DISABLE identifier
  • Doesn't pollute the global namespace (everything is in namespace doctest) and doesn't drag any headers with it
  • Very portable and well tested C++98 - per commit tested on CI with over 330 different builds (valgrind, sanitizers...)

This allows the framework to be used in more ways than any other - tests can be written directly in the production code!

Mantra: Tests can be considered a form of documentation and should be able to reside near the production code which they test.

  • This makes the barrier for writing tests much lower - you don't have to: 1) make a separate source file 2) include a bunch of stuff in it 3) add it to the build system and 4) add it to source control - You can just write the tests for a class or a piece of functionality at the bottom of its source file - or even header file!
  • Tests in the production code can be thought of as documentation or up-to-date comments - showing how an API is used
  • Testing internals that are not exposed through the public API and headers is no longer a mind-bending exercise
  • Test-driven development in C++ has never been easier!

The framework can be used like any other if you don't want/need to mix production code and tests - check out the features.

doctest is modeled after Catch and some parts of the code have been taken directly - check out the differences.

You can read more about it in the article of the february edition of ACCU Overload 2017.

Standard License Version download CII Best Practices Join the chat at https://gitter.im/onqtam/doctest Try it online

Documentation

Project:

Usage:

Contributing

Support the development of the project with donations! There is a list of planned features which are all important and big - see the roadmap. I took a break from working in the industry to make open source software so every cent is a big deal.

If you work for a company using doctest or have the means to do so, please consider financial support.

Contributions in the form of issues and pull requests are welcome as well - check out the Contributing page.

Sponsors

Want to see your name or the name of your company here? Consider donating!

⚑ Rockstar sponsors ⚑

πŸ’Ž Gold sponsors πŸ’Ž

  • Pascal Thomet
  • Mario Kostadinov

🍰 Silver sponsors 🍰

  • Dan Nissenbaum

πŸ” Bronze sponsors πŸ”

  • Sebastien Feldis
  • Zahari Karadzhov

About

The fastest feature-rich C++98/C++11 single-header testing framework for unit tests and TDD

http://bit.ly/1rsQ0Br

License:MIT License


Languages

Language:C++ 94.2%Language:Python 3.4%Language:CMake 2.4%