diff --git a/iceoryx_posh/test/moduletests/test_posh_runtime.cpp b/iceoryx_posh/test/moduletests/test_posh_runtime.cpp index 5eb2a6441d..17fe7e56f2 100644 --- a/iceoryx_posh/test/moduletests/test_posh_runtime.cpp +++ b/iceoryx_posh/test/moduletests/test_posh_runtime.cpp @@ -25,7 +25,6 @@ using iox::roudi::RouDiEnvironment; class PoshRuntimeTestAccess : public PoshRuntime { public: - using PoshRuntime::defaultRuntimeFactory; using PoshRuntime::factory_t; /// @attention do not use the setRuntimeFactory in a test with a running RouDiEnvironment using PoshRuntime::setRuntimeFactory; @@ -34,6 +33,16 @@ class PoshRuntimeTestAccess : public PoshRuntime : PoshRuntime(s) { } + + static PoshRuntime& getDefaultRuntime(iox::cxx::optional name) + { + return PoshRuntime::defaultRuntimeFactory(name); + } + + static void resetRuntimeFactory() + { + PoshRuntime::setRuntimeFactory(PoshRuntime::defaultRuntimeFactory); + } }; namespace @@ -42,7 +51,7 @@ bool callbackWasCalled = false; PoshRuntime& testFactory(iox::cxx::optional name) { callbackWasCalled = true; - return PoshRuntimeTestAccess::defaultRuntimeFactory(name); + return PoshRuntimeTestAccess::getDefaultRuntime(name); } } // namespace @@ -465,7 +474,7 @@ TEST(PoshRuntimeFactory_test, DISABLED_SetValidRuntimeFactorySucceeds) // do not use the setRuntimeFactory in a test with a running RouDiEnvironment PoshRuntimeTestAccess::setRuntimeFactory(testFactory); PoshRuntimeTestAccess::initRuntime("instance"); - PoshRuntimeTestAccess::setRuntimeFactory(PoshRuntimeTestAccess::defaultRuntimeFactory); + PoshRuntimeTestAccess::resetRuntimeFactory(); EXPECT_TRUE(callbackWasCalled); } @@ -478,5 +487,5 @@ TEST(PoshRuntimeFactory_test, DISABLED_SetEmptyRuntimeFactoryFails) EXPECT_DEATH({ PoshRuntimeTestAccess::setRuntimeFactory(PoshRuntimeTestAccess::factory_t()); }, "Cannot set runtime factory. Passed factory must not be empty!"); // just in case the previous test doesn't die and breaks the following tests - PoshRuntimeTestAccess::setRuntimeFactory(PoshRuntimeTestAccess::defaultRuntimeFactory); + PoshRuntimeTestAccess::resetRuntimeFactory(); }