aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/testlib/TestCase.qml
diff options
context:
space:
mode:
authorCharles Yin <yinyunqiao@gmail.com>2012-03-30 22:59:20 +1000
committerQt by Nokia <qt-info@nokia.com>2012-04-03 07:50:17 +0200
commit5b090cd9bc642582d214addba154ed022f6e537e (patch)
treee4474c9bc23cf2b90ca3b2d7702b55ad2b9d6192 /src/imports/testlib/TestCase.qml
parent817c0741d1d3e1dc1c505652ba764fe96b584aac (diff)
Add init_data() function for default data driven testing
If all or some test functions share the same test data, the test data can be put into init_data() function, this can reduce unnecessary code duplications. Change-Id: I118dd9c3c1d0f2f238aab6e25e5d8af80b3d3049 Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/imports/testlib/TestCase.qml')
-rw-r--r--src/imports/testlib/TestCase.qml7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml
index 1f9de5e998..694c01a710 100644
--- a/src/imports/testlib/TestCase.qml
+++ b/src/imports/testlib/TestCase.qml
@@ -475,6 +475,7 @@ Item {
function cleanupTestCase() {}
function init() {}
function cleanup() {}
+ function init_data() {}
function qtest_runInternal(prop, arg) {
try {
@@ -607,6 +608,10 @@ Item {
functionsToRun.splice(index, 1)
}
qtest_results.functionName = prop
+
+ if (!testCase.hasOwnProperty(datafunc))
+ datafunc = "init_data";
+
if (datafunc in testCase) {
if (qtest_runInternal(datafunc)) {
var table = qtest_testCaseResult
@@ -624,7 +629,7 @@ Item {
qtest_runFunction(prop, row)
qtest_results.dataTag = ""
}
- if (!haveData)
+ if (!haveData && datafunc != "init_data")
qtest_results.warn("no data supplied for " + prop + "() by " + datafunc + "()"
, util.callerFile(), util.callerLine());
qtest_results.clearTestTable()