CppEditor/CppTools: Don't continue in test function on failure

QVERIFY/QCOMPARE are meant to be called in the test function so that on
failure they just can "return" and thus skip subsequent code. Since we
use reusable test code in the test functions (the *TestCase classes), we
need to ensure that on failure no further test code is executed.

This mostly inlines the run function of the test classes into the
constructor.

Change-Id: I320ee032bdde0174ddfe3fdf3f9e18e19abf1d7f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2013-12-30 19:44:42 +01:00
parent c7f3ac4073
commit 0bd5917867
13 changed files with 354 additions and 522 deletions

View File

@@ -70,10 +70,12 @@ bool TestDocument::writeToDisk() const
TestCase::TestCase(bool runGarbageCollector)
: m_modelManager(CppModelManagerInterface::instance())
, m_succeededSoFar(false)
, m_runGarbageCollector(runGarbageCollector)
{
if (m_runGarbageCollector)
QVERIFY(garbageCollectGlobalSnapshot());
m_succeededSoFar = true;
}
TestCase::~TestCase()
@@ -85,6 +87,11 @@ TestCase::~TestCase()
QVERIFY(garbageCollectGlobalSnapshot());
}
bool TestCase::succeededSoFar() const
{
return m_succeededSoFar;
}
CPlusPlus::Snapshot TestCase::globalSnapshot()
{
return CppModelManagerInterface::instance()->snapshot();