1 Star 0 Fork 0

lzhkui / doctest

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

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 thanks to a fast, transparent and flexible test runner with a clean interface.

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

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
  • thread-safe - asserts (and logging) can be used from multiple threads spawned from a single test case - example
  • asserts can be used outside of a testing context - as a general purpose assert library - example
  • Doesn't pollute the global namespace (everything is in namespace doctest) and doesn't drag any headers with it
  • Very portable C++11 (use tag 1.2.9 for C++98) with over 180 different CI builds (static analysis, sanitizers...)
  • binaries (exe/dll) can use the test runner of another binary - so tests end up 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 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.

This table compares doctest / Catch / lest which are all very similar.

Checkout the CppCon 2017 talk on YouTube to get a better understanding of how the framework works and read about how to use it in the article of 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 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.

Stargazers over time

Stargazers over time

Logo

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

The MIT License (MIT) Copyright (c) 2016-2019 Viktor Kirilov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/lzhkui/doctest.git
git@gitee.com:lzhkui/doctest.git
lzhkui
doctest
doctest
master

搜索帮助