nickbruun/hayai

How to Stop/Fail a Benchmark if fixture SetUp() fails?

Opened this issue · 3 comments

Hi,

It seems there's not a way to stop/fail a benchmark whenever it is not possible to continue during SetUp().

class TestFixture : public ::hayai::Fixture
{
 public:
    virtual void SetUp() {
        test = new Test();
        if (!test->canContinue()) {
            // SHOULD STOP HERE!
        }
    }
    virtual void TearDown() {
        delete(test);
    }
    Test *test;
};

BENCHMARK_F()'s connected to the fixture above still continues to execute.

Cheers!

So, what you want is a way to fail during fixture setup?

Yes. Since some systems might throw errors, unable to connect to servers, initialization fails, etc. during SetUp().

Google Test Framework has some very useful macros for this sort of thing:
https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md#explicit-success-and-failure

I'd use it as inspiration.