Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

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

Open
roniemartinez opened this issue Mar 17, 2017 · 3 comments
Open

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

roniemartinez opened this issue Mar 17, 2017 · 3 comments

Comments

@roniemartinez
Copy link

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!

@nickbruun
Copy link
Owner

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

@roniemartinez
Copy link
Author

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

@conz27
Copy link
Contributor

conz27 commented May 17, 2018

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants