summaryrefslogtreecommitdiffstats
path: root/src/testlib/qplaintestlogger.cpp
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-08-29 16:50:52 +1000
committerQt by Nokia <qt-info@nokia.com>2011-08-31 03:44:17 +0200
commit527317748d00739994e3865b8f4e2525fc3ca2c7 (patch)
tree1cf509b1f0ea6bac9b878e6d079d49143813aa2c /src/testlib/qplaintestlogger.cpp
parent9be3851eb948a2e7a52273b222334e29d82fa437 (diff)
Remove ability to run tests in random order.
Remove the undocumented feature that allows test functions to be executed in random order. The feature was designed to expose unintended dependencies between test functions -- test functions are only supposed to depend on the initTestCase() and init() functions. Aside from the lack of documentation, there are a number of problems with this feature. Most importantly, running the tests in random order has only a 50% chance of exposing dependencies between test functions. A better strategy would be to run the test functions in reverse order and complain if that produces different results to running the tests in the normal order. Additionally, the random order is not deterministic, so even if a dependency is exposed during a test run, there's no guarantee that it will be exposed again. The feature allows the user to optionally supply a random seed to make the "random" order deterministic, but as rand() implementations are not identical across platforms, even that does not guarantee that dependencies between test functions will be exposed deterministically. Change-Id: I39eac34c532ccb988116778bbc5ab05d835874c5 Reviewed-on: http://codereview.qt.nokia.com/3720 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'src/testlib/qplaintestlogger.cpp')
-rw-r--r--src/testlib/qplaintestlogger.cpp22
1 files changed, 4 insertions, 18 deletions
diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp
index 44ec792400..bd1bc11582 100644
--- a/src/testlib/qplaintestlogger.cpp
+++ b/src/testlib/qplaintestlogger.cpp
@@ -345,7 +345,6 @@ void QPlainTestLogger::printBenchmarkResult(const QBenchmarkResult &result)
}
QPlainTestLogger::QPlainTestLogger()
-: randomSeed(9), hasRandomSeed(false)
{
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
InitializeCriticalSection(&QTest::outputCriticalSection);
@@ -368,17 +367,10 @@ void QPlainTestLogger::startLogging(const char *filename)
QTest::qt_snprintf(buf, sizeof(buf), "Testing %s\n",
QTestResult::currentTestObjectName());
} else {
- if (hasRandomSeed) {
- QTest::qt_snprintf(buf, sizeof(buf),
- "********* Start testing of %s *********\n"
- "Config: Using QTest library " QTEST_VERSION_STR
- ", Qt %s, Random seed %d\n", QTestResult::currentTestObjectName(), qVersion(), randomSeed);
- } else {
- QTest::qt_snprintf(buf, sizeof(buf),
- "********* Start testing of %s *********\n"
- "Config: Using QTest library " QTEST_VERSION_STR
- ", Qt %s\n", QTestResult::currentTestObjectName(), qVersion());
- }
+ QTest::qt_snprintf(buf, sizeof(buf),
+ "********* Start testing of %s *********\n"
+ "Config: Using QTest library " QTEST_VERSION_STR
+ ", Qt %s\n", QTestResult::currentTestObjectName(), qVersion());
}
outputMessage(buf);
}
@@ -440,10 +432,4 @@ void QPlainTestLogger::addMessage(MessageTypes type, const char *message,
printMessage(QTest::messageType2String(type), message, file, line);
}
-void QPlainTestLogger::registerRandomSeed(unsigned int seed)
-{
- randomSeed = seed;
- hasRandomSeed = true;
-}
-
QT_END_NAMESPACE