hayai icon indicating copy to clipboard operation
hayai copied to clipboard

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

Open roniemartinez opened this issue 7 years ago • 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!

roniemartinez avatar Mar 17 '17 05:03 roniemartinez

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

nickbruun avatar Mar 17 '17 15:03 nickbruun

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

roniemartinez avatar Mar 17 '17 17:03 roniemartinez

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.

conz27 avatar May 17 '18 00:05 conz27