• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

doc/H06-Feb-2018-

doctest/H06-Feb-2018-

examples/H06-Feb-2018-

scripts/H03-May-2022-

.clang-formatH A D06-Feb-20182.1 KiB

.gitattributesH A D06-Feb-201812

.gitignoreH A D06-Feb-2018355

.travis.ymlH A D06-Feb-201819.1 KiB

CHANGELOG.mdH A D06-Feb-201813.7 KiB

CONTRIBUTING.mdH A D06-Feb-20182.4 KiB

README.mdH A D06-Feb-20189.8 KiB

appveyor.ymlH A D06-Feb-20184.1 KiB

issue_template.mdH A D06-Feb-2018831

pull_request_template.mdH A D06-Feb-20181 KiB

README.md

1<h3>The fastest feature-rich C++98/C++11 single-header testing framework for unit tests and TDD</h3>
2
3<b>
4<table>
5    <tr>
6        <td>
7            master branch
8        </td>
9        <td>
10            Linux/OSX <a href="https://travis-ci.org/onqtam/doctest"><img src="https://travis-ci.org/onqtam/doctest.svg?branch=master"></a>
11        </td>
12        <td>
13            Windows <a href="https://ci.appveyor.com/project/onqtam/doctest/branch/master"><img src="https://ci.appveyor.com/api/projects/status/j89qxtahyw1dp4gd/branch/master?svg=true"></a>
14        </td>
15        <td>
16            <a href="https://coveralls.io/github/onqtam/doctest?branch=master"><img src="https://coveralls.io/repos/github/onqtam/doctest/badge.svg?branch=master"></a>
17        </td>
18        <td>
19            <a href="https://scan.coverity.com/projects/onqtam-doctest"><img src="https://scan.coverity.com/projects/7865/badge.svg"></a>
20        </td>
21    </tr>
22    <tr>
23        <td>
24            dev branch
25        </td>
26        <td>
27            Linux/OSX <a href="https://travis-ci.org/onqtam/doctest"><img src="https://travis-ci.org/onqtam/doctest.svg?branch=dev"></a>
28        </td>
29        <td>
30            Windows <a href="https://ci.appveyor.com/project/onqtam/doctest/branch/dev"><img src="https://ci.appveyor.com/api/projects/status/j89qxtahyw1dp4gd/branch/dev?svg=true"></a>
31        </td>
32        <td>
33            <a href="https://coveralls.io/github/onqtam/doctest?branch=dev"><img src="https://coveralls.io/repos/github/onqtam/doctest/badge.svg?branch=dev"></a>
34        </td>
35        <td>
36        </td>
37    </tr>
38</table>
39</b>
40
41**doctest** is a new C++ testing framework but is by far the fastest both in compile times (by [**orders of magnitude**](doc/markdown/benchmarks.md)) and runtime compared to other feature-rich alternatives. It brings the ability of compiled languages such as [**D**](https://dlang.org/spec/unittest.html) / [**Rust**](https://doc.rust-lang.org/book/testing.html) / [**Nim**](https://nim-lang.org/docs/unittest.html) to have tests written directly in the production code by providing a fast, transparent and flexible test runner with a clean interface.
42
43[<img src="https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png" align="right">](http://www.patreon.com/onqtam)
44
45The framework is and will stay free but needs your support to sustain its development. There are lots of <a href="doc/markdown/roadmap.md"><b>new features</b></a> 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.
46
47[<img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" align="right">](https://www.paypal.me/onqtam/10)
48
49A complete example with a self-registering test that compiles to an executable looks like this:
50
51![cover-example](scripts/data/using_doctest_888px_wide.gif)
52
53There are many C++ testing frameworks - [Catch](https://github.com/philsquared/Catch), [Boost.Test](http://www.boost.org/doc/libs/1_64_0/libs/test/doc/html/index.html), [UnitTest++](https://github.com/unittest-cpp/unittest-cpp), [cpputest](https://github.com/cpputest/cpputest), [googletest](https://github.com/google/googletest) and many [other](https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C.2B.2B).
54
55The **key** differences between it and other testing frameworks are that it is light and unintrusive:
56- Ultra light on compile times both in terms of [**including the header**](doc/markdown/benchmarks.md#cost-of-including-the-header) and writing [**thousands of asserts**](doc/markdown/benchmarks.md#cost-of-an-assertion-macro)
57- Doesn't produce any warnings even on the [**most aggressive**](scripts/cmake/common.cmake#L84) warning levels for **MSVC**/**GCC**/**Clang**
58- Offers a way to remove **everything** testing-related from the binary with the [**```DOCTEST_CONFIG_DISABLE```**](doc/markdown/configuration.md#doctest_config_disable) identifier
59- Doesn't pollute the global namespace (everything is in namespace ```doctest```) and doesn't drag **any** headers with it
60- Very [**portable**](doc/markdown/features.md#extremely-portable) C++98 - per commit tested on CI with over 330 different builds (static analysis, sanitizers...)
61
62![cost-of-including-the-framework-header](scripts/data/benchmarks/header.png)
63
64This allows the framework to be used in more ways than any other - tests can be written directly in the production code!
65
66Mantra: *Tests can be considered a form of documentation and should be able to reside near the production code which they test.*
67
68- 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!
69- Tests in the production code can be thought of as documentation or up-to-date comments - showing how an API is used
70- Testing internals that are not exposed through the public API and headers is no longer a mind-bending exercise
71- [**Test-driven development**](https://en.wikipedia.org/wiki/Test-driven_development) in C++ has never been easier!
72
73The framework can be used like any other if you don't want/need to mix production code and tests - check out the [**features**](doc/markdown/features.md).
74
75**doctest** is modeled after [**Catch**](https://github.com/philsquared/Catch) and some parts of the code have been taken directly - check out [**the differences**](doc/markdown/faq.md#how-is-doctest-different-from-catch).
76
77[This table](https://github.com/martinmoene/catch-lest-other-comparison) compares **doctest** / [**Catch**](https://github.com/philsquared/Catch) / [**lest**](https://github.com/martinmoene/lest) which are all very similar.
78
79[![Standard](https://img.shields.io/badge/c%2B%2B-98/11/14/17-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B#Standardization)
80[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
81[![Version](https://badge.fury.io/gh/onqtam%2Fdoctest.svg)](https://github.com/onqtam/doctest/releases)
82[![download](https://img.shields.io/badge/download%20%20-latest-blue.svg)](https://raw.githubusercontent.com/onqtam/doctest/master/doctest/doctest.h)
83[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/503/badge)](https://bestpractices.coreinfrastructure.org/projects/503)
84[![Join the chat at https://gitter.im/onqtam/doctest](https://badges.gitter.im/onqtam/doctest.svg)](https://gitter.im/onqtam/doctest?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
85[![Try it online](https://img.shields.io/badge/try%20it-online-orange.svg)](https://wandbox.org/permlink/YSid52GI4qMDFvs1)
86<!--
87[![Language](https://img.shields.io/badge/language-C++-blue.svg)](https://isocpp.org/)
88[![documentation](https://img.shields.io/badge/documentation%20%20-online-blue.svg)](https://github.com/onqtam/doctest/blob/master/doc/markdown/readme.md#reference)
89-->
90
91Checkout the [**CppCon 2017 talk**](https://cppcon2017.sched.com/event/BgsI/mix-tests-and-production-code-with-doctest-implementing-and-using-the-fastest-modern-c-testing-framework) on [**YouTube**](https://www.youtube.com/watch?v=eH1CxEC29l8) to get a better understanding of how the framework works and read about how to use it in [**the article**](https://accu.org/var/uploads/journals/Overload137.pdf) of the february edition of ACCU Overload 2017!
92
93[![CppCon 2017 talk about doctest on youtube](scripts/data/youtube-cppcon-talk-thumbnail.png)](https://www.youtube.com/watch?v=eH1CxEC29l8)
94
95Documentation
96-------------
97
98Project:
99
100- [Features and design goals](doc/markdown/features.md) - the complete list of features
101- [Roadmap](doc/markdown/roadmap.md) - upcoming features
102- [Benchmarks](doc/markdown/benchmarks.md) - compile-time and runtime supremacy
103- [Contributing](CONTRIBUTING.md) - how to make a proper pull request
104- [Changelog](CHANGELOG.md) - generated changelog based on closed issues/PRs
105
106Usage:
107
108- [Tutorial](doc/markdown/tutorial.md) - make sure you have read it before the other parts of the documentation
109- [Assertion macros](doc/markdown/assertions.md)
110- [Test cases, subcases and test fixtures](doc/markdown/testcases.md)
111- [Parameterized test cases](doc/markdown/parameterized-tests.md)
112- [Command line](doc/markdown/commandline.md)
113- [Logging macros](doc/markdown/logging.md)
114- [```main()``` entry point](doc/markdown/main.md)
115- [Configuration](doc/markdown/configuration.md)
116- [String conversions](doc/markdown/stringification.md)
117- [FAQ](doc/markdown/faq.md)
118- [Build systems](doc/markdown/build-systems.md)
119- [Examples](examples)
120
121Contributing
122------------
123
124[<img src="https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png" align="right">](http://www.patreon.com/onqtam)
125
126Support the development of the project with donations! There is a list of planned features which are all important and big - see the [**roadmap**](doc/markdown/roadmap.md). I took a break from working in the industry to make open source software so every cent is a big deal.
127
128[<img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" align="right">](https://www.paypal.me/onqtam/10)
129
130If you work for a company using **doctest** or have the means to do so, please consider financial support.
131
132Contributions in the form of issues and pull requests are welcome as well - check out the [**Contributing**](CONTRIBUTING.md) page.
133
134
135Sponsors
136--------
137
138Want to see your name or the name of your company here? Consider donating!
139
140### :zap: Rockstar sponsors :zap:
141
142### :gem: Gold sponsors :gem:
143
144- Pascal Thomet
145- Mario Kostadinov
146
147### :cake: Silver sponsors :cake:
148
149- Dan Nissenbaum
150
151### :hamburger: Bronze sponsors :hamburger:
152
153- Sebastien Feldis
154- Zahari Karadzhov
155