Skip to content

Qters/QrTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

main

#include "testsuitefactory.h"
#include "runner.h"

int main(int argc, char *argv[])
{
    Q_UNUSED(argc);
    Q_UNUSED(argv);
    return Qters::QrTest::Runner::runAllTest ();
}

how to append new test case

1. create class file, inherit from QObject
2. #include "testsuitefactory.h"
3. add macro before class name like this:
  FORMAT: class TESTSUITE(class_name) class_name : public QObject
4. one private slot is one test case
Qt Test Tutorial:http://doc.qt.io/qt-5/qtest-tutorial.html

demo

demo class's header

#ifndef TST_DEMO_H
#define TST_DEMO_H

#include "testsuitefactory.h"
class TESTSUITE(TestDemo) TestDemo : public QObject
{
    Q_OBJECT

private slots:
    void toUpper();
    void toLower();
};

#endif // TST_DEMO_H

demo class's cpp

#include "tst_demo.h"

#include <QtTest/qtestcase.h>

void TestDemo::toUpper() {
    QString str = "hello";
    QCOMPARE(str.toUpper(), QString("HELLO"));
}

void TestDemo::toLower() {
    QString str = "Hello";
    QCOMPARE(str.toLower(), QString("hello"));
}

About

test frame for Qt-based C++ apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages