tpunitpp icon indicating copy to clipboard operation
tpunitpp copied to clipboard

Adds an optional test name

Open tylerkaraszewski opened this issue 9 years ago • 5 comments

This change adds an (optional) name to a TestFixture.

This allows you to create a TestFixture as such:

MyTest() : tpunit::TestFixture(BEFORE_CLASS(MyTest::setup),
                                             TEST(MyTest::testMyThing),
                                             AFTER_CLASS(StripeTest::tearDown)) {
    NAME(MyTest);
}

And then later on invoke your test by doing:

set<string> include, exclude;
include.insert("MyTest");
tpunit::Tests::run(include, exclude);

This makes it easy to conditionally separate groups of tests and allows for, for instance, the following:

if (each_build) {
    set<string> include, exclude;
    exclude.insert("SlowTest");
    tpunit::Tests::run(include, exlude);
}
else if (nightly_comprehensive) {
    // Just run everything.
    tpunit::Tests::run();
}

Unnamed tests will still be run when include is left empty.

tylerkaraszewski avatar May 03 '16 00:05 tylerkaraszewski

@tylerkaraszewski: Thanks for the pull request! @flodnv put in a similar feature request (issue #6). I think there is some overlap in the functionality. Does the feedback there make sense for you? Specifically the ability to include/exclude specific tests.

@flodnv: LMK if you have thoughts as well.

tpounds avatar May 04 '16 18:05 tpounds

@tpounds Thanks for the feedback. I've updated the PR to support both including and excluding lists of tests, and updated main to take these arguments on the command line. You can test by building main and running with the options --include=TPUnitPPTest and --exclude=TPUnitPPTest.

I tried to keep the required includes to a minimum, but this change does depend on <set> and <string>, but presumably those are pretty universally available.

tylerkaraszewski avatar May 04 '16 21:05 tylerkaraszewski

Awesome @tylerkaraszewski, thanks much!

👍

flodnv avatar May 05 '16 09:05 flodnv

@tpounds Any further feedback on this?

tylerkaraszewski avatar May 31 '16 17:05 tylerkaraszewski

@tpounds I get this probably isn't a huge priority for you, but we'd prefer to be able to use the master branch here rather than our own fork for this, if you have no problems merging it.

tylerkaraszewski avatar Aug 31 '16 21:08 tylerkaraszewski