diff options
author | Jeremie Guichard <djebrest@gmail.com> | 2017-03-03 13:33:25 +0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-03-04 12:03:33 -0800 |
commit | 5caa9b23fe3195c758f9b6f1a9ab5f7bf88ee45c (patch) | |
tree | 0eb92e14fdda8fc9b8f858df3204970b2ce2fde7 /tests | |
parent | 16a321d43b654cd756f5e2b54d72bad80e493b69 (diff) | |
download | subsurface-5caa9b23fe3195c758f9b6f1a9ab5f7bf88ee45c.tar.gz |
Use QTest cleanup method for proper test shutdown
In case of QCOMPARE failure, code following the comparison
is not executed, this results in application state not being
properly resorted and often gives several test failures,
when only one test really fails.
Using QTest cleanup method allows restoring proper state,
before next test is executed.
Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testgitstorage.cpp | 11 | ||||
-rw-r--r-- | tests/testgitstorage.h | 2 | ||||
-rw-r--r-- | tests/testmerge.cpp | 7 | ||||
-rw-r--r-- | tests/testmerge.h | 2 |
4 files changed, 14 insertions, 8 deletions
diff --git a/tests/testgitstorage.cpp b/tests/testgitstorage.cpp index 46e77142d..f2fe3f0e1 100644 --- a/tests/testgitstorage.cpp +++ b/tests/testgitstorage.cpp @@ -59,6 +59,11 @@ void TestGitStorage::initTestCase() QCOMPARE(localCacheDirectory.removeRecursively(), true); } +void TestGitStorage::cleanup() +{ + clear_dive_file_data(); +} + void TestGitStorage::testGitStorageLocal_data() { // test different path we may encounter (since storage depends on user name) @@ -92,7 +97,6 @@ void TestGitStorage::testGitStorageLocal() QString readin = orgS.readAll(); QString written = outS.readAll(); QCOMPARE(readin, written); - clear_dive_file_data(); } void TestGitStorage::testGitStorageCloud() @@ -115,7 +119,6 @@ void TestGitStorage::testGitStorageCloud() QString readin = orgS.readAll(); QString written = outS.readAll(); QCOMPARE(readin, written); - clear_dive_file_data(); } void TestGitStorage::testGitStorageCloudOfflineSync() @@ -165,7 +168,6 @@ void TestGitStorage::testGitStorageCloudOfflineSync() readin = orgS2.readAll(); written = outS2.readAll(); QCOMPARE(readin, written); - clear_dive_file_data(); } void TestGitStorage::testGitStorageCloudMerge() @@ -213,7 +215,6 @@ void TestGitStorage::testGitStorageCloudMerge() QString readin = orgS.readAll(); QString written = outS.readAll(); QCOMPARE(readin, written); - clear_dive_file_data(); } void TestGitStorage::testGitStorageCloudMerge2() @@ -268,7 +269,6 @@ void TestGitStorage::testGitStorageCloudMerge2() QString readin = orgS.readAll(); QString written = outS.readAll(); QCOMPARE(readin, written); - clear_dive_file_data(); } void TestGitStorage::testGitStorageCloudMerge3() @@ -334,7 +334,6 @@ void TestGitStorage::testGitStorageCloudMerge3() QCOMPARE(save_dives("./SampleDivesMerge3.ssrf"), 0); // we are not trying to compare this to a pre-determined result... what this test // checks is that there are no parsing errors with the merge - clear_dive_file_data(); } QTEST_GUILESS_MAIN(TestGitStorage) diff --git a/tests/testgitstorage.h b/tests/testgitstorage.h index 579aa33d3..d84a8e544 100644 --- a/tests/testgitstorage.h +++ b/tests/testgitstorage.h @@ -8,6 +8,8 @@ class TestGitStorage : public QObject Q_OBJECT private slots: void initTestCase(); + void cleanup(); + void testGitStorageLocal_data(); void testGitStorageLocal(); void testGitStorageCloud(); diff --git a/tests/testmerge.cpp b/tests/testmerge.cpp index 450aba2e9..8c2b3482d 100644 --- a/tests/testmerge.cpp +++ b/tests/testmerge.cpp @@ -10,6 +10,11 @@ void TestMerge::initTestCase() Q_INIT_RESOURCE(subsurface); } +void TestMerge::cleanup() +{ + clear_dive_file_data(); +} + void TestMerge::testMergeEmpty() { /* @@ -31,7 +36,6 @@ void TestMerge::testMergeEmpty() while(readin.size() && written.size()){ QCOMPARE(written.takeFirst().trimmed(), readin.takeFirst().trimmed()); } - clear_dive_file_data(); } void TestMerge::testMergeBackwards() @@ -55,7 +59,6 @@ void TestMerge::testMergeBackwards() while(readin.size() && written.size()){ QCOMPARE(written.takeFirst().trimmed(), readin.takeFirst().trimmed()); } - clear_dive_file_data(); } QTEST_GUILESS_MAIN(TestMerge) diff --git a/tests/testmerge.h b/tests/testmerge.h index 771afc4db..2acb1dace 100644 --- a/tests/testmerge.h +++ b/tests/testmerge.h @@ -7,6 +7,8 @@ class TestMerge : public QObject{ Q_OBJECT private slots: void initTestCase(); + void cleanup(); + void testMergeEmpty(); void testMergeBackwards(); }; |