Skip to content

RC_PARAMS and GoogleTest #297

Open
Open
@kalaracey

Description

Hey, thanks for the great library. I was wondering if it's possible to set RC_PARAMS with the GoogleTest integration from within the test. I tried setting the environment variable in my test suite constructor to no avail:

#include <gtest/gtest.h>
#include <cstdlib>
#include <rapidcheck/gtest.h>
#include <vector>

class TestSuite : public ::testing::Test {
  protected:
    TestSuite() {
      putenv("RC_PARAMS=max_success=100000");
    }
};

// ...

RC_GTEST_FIXTURE_PROP(TestSuite, RapidCheck, (std::vector<int> arg)) {
  // ...
  RC_ASSERT(/* ... */);
}

The only output from RapidCheck I see is like

Using configuration: seed=13725330511029654191

FWIW, using putenv from main did work, as in

#include <rapidcheck.h>
#include <vector>
#include <cstdlib>

int main() {
  putenv("RC_PARAMS=max_success=100000");
  rc::check("my property", [](std::vector<int>) { /* ... */ });
  return 0;
}

With that, I see

Using configuration: max_success=100000 seed=3088896386735555752

- my property
OK, passed 100000 tests

Thanks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions