Allowing one-time testing::Environment SetUp/TearDown with --gtest_repeat

1,054 views
Skip to first unread message

kingofmybones

unread,
Jul 6, 2015, 10:58:05 AM7/6/15
to googletes...@googlegroups.com
I have some tests that I would like to run with --gtest_repeat but I use Environment subclasses that require one-time (per process) initialization and finalization. For these tests it would be helpful if I could specify an additional option to invoke Environment SetUp()/TearDown() only before first repetition/after last repetition. I would be happy to look into making the modifications myself for potential inclusion in google test, but would like to assess acceptance before undertaking this.

I would suggest something like a --gtest_one_time_environment to be optionally used in conjunction with gtest_repeat (ignored if gtest_repeat not selected). Effect would be to modify the default repetition pattern from:

START Test::Setup() (Environment::SetUp() TEST Environment::TearDown())* Test::TearDown() END

to:

START Test::Setup() Environment::SetUp() TEST* Environment::TearDown() Test::TearDown() END

Whadyall think?

Billy Donahue

unread,
Jul 6, 2015, 11:17:33 AM7/6/15
to kingofmybones, googletes...@googlegroups.com
I think this is a user-level issue.
All the hooks you would need as a user should be there.
--

---
You received this message because you are subscribed to the Google Groups "Google C++ Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

kingofmybones

unread,
Jul 6, 2015, 11:59:52 AM7/6/15
to googletes...@googlegroups.com, ktbr...@gmail.com
I'm not sure what user-level hooks you are referring to. All I see in the documentation around gtest_repeat is "If your test program contains global set-up/tear-down code registered using AddGlobalTestEnvironment(), it will be repeated in each iteration as well, as the flakiness may be in it." I'm looking for command-line options/environment settings that can suppress repeating Environment setup/teardown so that setup occurs only once (setup before first test repitition, teardown after last repetition).

Billy Donahue

unread,
Jul 6, 2015, 12:13:02 PM7/6/15
to kingofmybones, Google C++ Testing Framework
I would like to keep the idea of "do this only once" out of gtest.
Gtest deals with abstract hooks like TestEventListener and Environment.

If your particular kind of Environment or TestEventListener has some behavior that should only happen the first time a hook is invoked, you can do that privately with a bool or a counter or whatever.

I don't want to expand the gtest API with special-case needs like this.

--
Reply all
Reply to author
Forward
0 new messages