To be sincere, I think this question should be closed and that you should start reading some of the books you've been provided. Also, I don't see what there is to test here, maybe the result of the string? However, see if this helps you:
UnitTests.pro
QT += testlib
QT -= gui
TARGET = tst_unitteststest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += tst_unitteststest.cpp task.cpp
DEFINES += SRCDIR=\\\"$$PWD/\\\"
HEADERS += task.h
tst_unitteststest.cpp
#include <QString>
#include <QtTest>
#include "task.h"
class UnitTestsTest : public QObject
{
Q_OBJECT
public:
UnitTestsTest();
private Q_SLOTS:
void initTestCase();
void cleanupTestCase();
void testCase1();
};
UnitTestsTest::UnitTestsTest()
{
}
void UnitTestsTest::initTestCase()
{
}
void UnitTestsTest::cleanupTestCase()
{
}
void UnitTestsTest::testCase1()
{
QVERIFY2(true, "Failure");
Task t("name", "desc", new QDate(1, 1, 2012), new QTime(0, 0), new QTime(1, 0), false);
QVERIFY(t.toString() == "name 00:00 - 01:00");
}
QTEST_APPLESS_MAIN(UnitTestsTest)
#include "tst_unitteststest.moc"
Consider that there are mem leaks here... but I don't know how you want your class to become. The test will pass here of course.