Within a Qt Unit-test, how can the program retrieve the name of the test being run?
Code looks something like this:
#include <QtTest>
class MyTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase()
{
}
void testCase1()
{
}
void cleanupTestCase()
{
// Want to print "finished testCase1" here
}
};
QTEST_APPLESS_MAIN(MyTest)
e.g. can it find out the name of the signal/slot that triggered the test?
QTest::currentTestFunction()
Should return the name of the current test function as a const char *
As an aside, perhaps you want to put it within a cleanup
function, and not cleanupTestCase
? It appears that cleanup
is called after each test, while cleanupTestCase
will be called only after all tests are finished.