Create anchor with exactly same details than original test for ensure it will pass all test filters the same way as original

This commit is contained in:
Gabriel Schlozer 2016-05-17 15:07:03 +02:00
parent bbdf7c7392
commit d49ddee296
2 changed files with 19 additions and 9 deletions

View file

@ -48,15 +48,6 @@ void ParameterizedTestAbstract::ensureInitialized()
{
TestListNode* currentTest = retrieveCurrentTest();
if (_testAnchor == nullptr)
{
_testAnchor = new TestAnchor("ParameterizedTestAnchor", currentTest->m_test->m_details.suiteName, *this);
}
if (_testAnchorNode == nullptr)
{
_testAnchorNode = new TestListNode(_testAnchor);
}
if (_lastTest != currentTest)
{
_lastTest = currentTest;
@ -110,6 +101,7 @@ void ParameterizedTestAbstract::onNewIteration(bool first)
{
throw runtime_error("No values for parameterized test");
}
newAnchor();
}
else
{
@ -134,6 +126,23 @@ void ParameterizedTestAbstract::onNewIteration(bool first)
}
void ParameterizedTestAbstract::newAnchor()
{
if (_testAnchor != nullptr)
{
delete _testAnchor;
}
if (_testAnchorNode != nullptr)
{
delete _testAnchorNode;
}
// Important: create anchor with exactly same details than original test for ensure it will pass all test filters the same way as original
_testAnchor = new TestAnchor(_lastTest->m_test->m_details.testName, _lastTest->m_test->m_details.suiteName, *this);
_testAnchorNode = new TestListNode(_testAnchor);
}
ParameterizedTestAbstract::TestAnchor::TestAnchor(char const* testName, char const* suiteName, ParameterizedTestAbstract & pt)
: Test(testName, suiteName),
_pt(pt)

View file

@ -42,6 +42,7 @@ namespace UnitTest
bool hasMoreValues(int advance = 0) const;
void onNewIteration(bool first);
void newAnchor();
size_t _iteration;
TestListNode* _lastTest;