summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2010-10-03 17:10:28 +1000
committerRhys Weatherley <rhys.weatherley@nokia.com>2010-10-03 17:10:28 +1000
commita96583615ffbcb32726df56d206953f4b238e98d (patch)
tree9dd8195950476e3710186dcc97e14203842bd9b4
parent9eea085d7edd91988eba013d35756b5dab6408db (diff)
Add support for optional TestCase elements
-rw-r--r--QtTest/TestCase.qml15
-rw-r--r--QtTest/testlogger.js16
-rw-r--r--examples/ItemTests.qml9
3 files changed, 40 insertions, 0 deletions
diff --git a/QtTest/TestCase.qml b/QtTest/TestCase.qml
index 3625140..3f28490 100644
--- a/QtTest/TestCase.qml
+++ b/QtTest/TestCase.qml
@@ -17,6 +17,10 @@ Item {
// Set to true when the test is running but not yet complete.
property bool running: false
+ // Set to true if the test doesn't have to run (because some
+ // other test failed which this one depends on).
+ property bool optional: false
+
// Internal private state
property string currentTestCase
property bool expectingFail
@@ -149,8 +153,19 @@ Item {
}
}
+ onOptionalChanged: {
+ if (!completed) {
+ if (optional)
+ TestLogger.log_optional_test(testId)
+ else
+ TestLogger.log_mandatory_test(testId)
+ }
+ }
+
Component.onCompleted: {
testId = TestLogger.log_register_test(name)
+ if (optional)
+ TestLogger.log_optional_test(testId)
prevWhen = when
if (when && !completed && !running)
run()
diff --git a/QtTest/testlogger.js b/QtTest/testlogger.js
index 34e73a0..7f360f1 100644
--- a/QtTest/testlogger.js
+++ b/QtTest/testlogger.js
@@ -81,6 +81,22 @@ function log_register_test(name)
return testId
}
+function log_optional_test(testId)
+{
+ log_init_results()
+ var index = Qt.testResults.testCases.indexOf(testId)
+ if (index >= 0)
+ Qt.testResults.testCases.splice(index, 1)
+}
+
+function log_mandatory_test(testId)
+{
+ log_init_results()
+ var index = Qt.testResults.testCases.indexOf(testId)
+ if (index == -1)
+ Qt.testResults.testCases.push(testId)
+}
+
function log_start_test()
{
log_init_results()
diff --git a/examples/ItemTests.qml b/examples/ItemTests.qml
index a150735..a83e514 100644
--- a/examples/ItemTests.qml
+++ b/examples/ItemTests.qml
@@ -30,4 +30,13 @@ Rectangle {
verify(bar)
}
}
+
+ TestCase {
+ when: false
+ optional: true
+
+ function test_not_run() {
+ verify(false)
+ }
+ }
}