Do not save the execution report of each plugin
[grantlee:grantlee.git] / templates / tests / coverageobject.cpp
1 #include "coverageobject.h"
2 #include <QTest>
3 #include <QMetaObject>
4 #include <QDir>
5 #include <QString>
6 #include <QDebug>
7 #include <QtDebug>
8 #include <QLibrary>
9
10 #include "grantlee_paths.h"
11
12 void CoverageObject::init()
13 {
14   initTest();
15 }
16
17 QString CoverageObject::generateTestName() const
18 {
19   QString test_name;
20   test_name+=QString::fromAscii(metaObject()->className());
21   test_name+=QString::fromAscii("/");
22   test_name+=QString::fromAscii(QTest::currentTestFunction());
23   if (QTest::currentDataTag())
24   {
25     test_name+=QString::fromAscii("/");
26     test_name+=QString::fromAscii(QTest::currentDataTag());
27   }
28   return test_name;
29 }
30
31 void CoverageObject::saveCoverageData()
32 {
33 #ifdef __COVERAGESCANNER__
34   QString test_name;
35   test_name += generateTestName();
36
37   __coveragescanner_testname(test_name.toStdString().c_str());
38   if (QTest::currentTestFailed())
39     __coveragescanner_teststate("FAILED");
40   else
41     __coveragescanner_teststate("PASSED") ;
42   __coveragescanner_save();
43   __coveragescanner_testname("");
44   __coveragescanner_clear();
45 #endif
46 }
47
48 void CoverageObject::cleanup()
49 {
50   cleanupTest();
51   saveCoverageData();
52 }
53
54 #include "coverageobject.moc"