Comments (2)
I'm not sure I fully understand your case.
So far your library seems header-only (with no tests in the header) and the only source files are with tests - so users of the library will not have them in their production code when using only the header.
A potential workflow problem I see is if you write tests in your header, and ship the header with the following:
#define DOC_TEST_CONFIG_DISABLE
#include "doctest.h"
// your tests that are supposed to be disabled in the 'production' header - when released to customers.
I think an option for your situation (if I sort-of understand it) is to add a 'tag' to all your tests (add a specific string in the test case names):
TEST_CASE("[myLibrary] Testing Point.hpp") {
// ...
and then the user can exclude them with filters when he is providing the main() entry point like this:
doctest::Context context(argc, argv);
context.addFilter("test-case-exclude", "*myLibrary*");
This way you won't have to think about disabling them for the user.
If you can clarify a bit more the situation I might be able to come up with a different solution.
from doctest.
So far your library seems header-only (with no tests in the header)…
Yeah, I’ve since moved the tests out of the main source. You can see how I had it in earlier changesets.
To be honest, I think the real answer is not to “pollute” libraries (libraries specifically) with test code, so I went with that. The solution you gave actually does almost exactly what I want if the filter is added in my own code inside a pre-processor guard (I mean, I haven’t tried it, since I’ve moved on, but still).
Thanks for the help.
from doctest.
Related Issues (20)
- Doctest segfault with CHECK in implement w/o main HOT 1
- Compilation error on minimal function taking and returning std::vector<std::pair<int, int>> HOT 3
- Abort execution of a subcase without halting the entire test case
- Request: Control via environment variables
- Suggestion: document a simpler CMake integration via FetchContent HOT 2
- Tests fail to compile: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage], etc HOT 2
- Warning from new CMake HOT 3
- Add DISCOVERY_MODE to doctest_discover_tests
- doctest outputs ANSI escapes to non-color TTYs, resulting in visible junk HOT 1
- Build error "error: zero as null pointer constant” (Xcode 15)
- doctest_discover_tests fails with ASAN on Windows HOT 1
- how to use with c++20 modules
- Add an "AND_GIVEN" macro for BDD-style test cases
- CodeQL warning in doctest header (use after free)
- Missing support for std::format HOT 1
- When one subcase fails, other independent sibling subcases are not executed anymore HOT 2
- Cannot include `doctest.h` in multiple translation units for Arduino (avr-gcc-7.3.0) HOT 1
- Feature request: predicate on CHECK_THROWS
- TYPE_TO_STRING does not work inside a TEST_SUITE / namespace HOT 1
- Access violation on Winlibs MinGW-w64 Clang on Windows HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from doctest.