Code Monkey home page Code Monkey logo

Comments (2)

onqtam avatar onqtam commented on May 20, 2024

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.

atimholt avatar atimholt commented on May 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.