Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

The fastest feature-rich C++11/14/17/20/23 single-header testing framework

License

NotificationsYou must be signed in to change notification settings

doctest/doctest

Repository files navigation

master branch
dev branch

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

StandardLicensedownloadCII Best PracticesChat - DiscordTry it online

The framework is and will stay free but needs your support to sustain its development. There are lots ofnew features and maintenance to do. If you work for a company usingdoctest 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 andothers.

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

  • Ultra light on compile times both in terms ofincluding the header and writingthousands of asserts
  • Doesn't produce any warnings even on themost aggressive warning levels forMSVC/GCC/Clang
  • Can removeeverything testing-related from the binary with theDOCTEST_CONFIG_DISABLE identifier
  • thread-safe - asserts can be used from multiple threads spawned from a single test case -example
  • asserts can be usedoutside of a testing context - as a general purpose assert library -example
  • No global namespace pollution (everything is indoctest::) & doesn't dragany headers with it
  • Portable C++11 (use tag1.2.9 for C++98) with over 100 different CI builds (static analysis, sanitizers..)
  • binaries (exe/dll) can use the test runner of another binary => tests in a single registry -example

cost-of-including-the-framework-header

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

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

  • This makes the barrier for writing testsmuch lower - you don't have to:1) make a separate source file2) include a bunch of stuff in it3) add it to the build system and4) 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/up-to-date comments - showcasing the APIs
  • 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 just like any other without mixing production code and tests - check out thefeatures.

doctest is modeled afterCatch and some parts of the code have been taken directly - check outthe differences.

This table comparesdoctest /Catch /lest which are all very similar.

Checkout theCppCon 2017 talk onYouTube to get a better understanding of how the framework works and read about how to use it inthe JetBrains article - highlighting the unique aspects of the framework! On a short description on how to use the framework along production code you could refer tothis GitHub issue. There is also anolder article in the february edition of ACCU Overload 2017.

CppCon 2017 talk about doctest on youtube

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 theroadmap.

If you work for a company usingdoctest 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 theContributing page.

Stargazers over time

Stargazers over time

Logo

Thelogo is licensed under a Creative Commons Attribution 4.0 International License. Copyright © 2019area55git  License: CC BY 4.0


[8]ページ先頭

©2009-2025 Movatter.jp