Jenkins est un lanceur de tache.
Il permet notamment de lancer une build C++ ou java.
#include <QtTest/QtTest> class TestQString: public QObject { Q_OBJECT private slots: void toUpper(); void myFirstBenchmark() { QString string1; QString string2; QBENCHMARK { –> utilisation de QBENCHMARK string1.localeAwareCompare(string2); } } }; void TestQString::toUpper() { QString str = "Hello"; QVERIFY(str.toUpper() == "HELLO"); –> ou plus verbeux: QCOMPARE(str.toUpper(), QString("HELLO")); } QTEST_MAIN(TestQString) #include "testqstring.moc"
class TestQString: public QObject { Q_OBJECT private slots: void toUpper_data(); void toUpper(); }; void TestQString::toUpper_data() { QTest::addColumn<QString>("string"); QTest::addColumn<QString>("result"); QTest::newRow("all lower") « "hello" « "HELLO"; QTest::newRow("mixed") « "Hello" « "HELLO"; QTest::newRow("all upper") « "HELLO" « "HELLO"; } void TestQString::toUpper() { QFETCH(QString, string); QFETCH(QString, result); QCOMPARE(string.toUpper(), result); } index name string result 0 all lower "hello" HELLO 1 mixed "Hello" HELLO 2 all upper "HELLO" HELLO
http://doc.qt.io/qt-5/qttestlib-tutorial3-example.html
#include <QtWidgets> #include <QtTest/QtTest> class TestGui: public QObject { Q_OBJECT private slots: void testGui(); }; void TestGui::testGui() { QLineEdit lineEdit; QTest::keyClicks(&lineEdit, "hello world"); QCOMPARE(lineEdit.text(), QString("hello world")); }
QTestLib gére les evenements graphiques
Trucs pour écrire des tests qt: QCOMPARE, QVERIFY2, QTRY_COMPARE, etc…
https://wiki.qt.io/Writing_Unit_Tests
Selon google:
Small tests are mostly (but not always) automated and exercise the code within a single function or module. The focus is on typical functional issues, data corruption, error conditions, and off-by-one mistakes. Small tests are of short duration, usually running in seconds or less. They are most likely written by a Software Engineer (SWE), less often by an Software Engineer in Test (SET), and hardly ever by a Test Engineer (TE). [8] Small tests generally require sample environments to run and be tested in. Software developers rarely write small tests but might run them when they are trying to diagnose a particular failure. The question a small test attempts to answer is, “Does this code do what it is supposed to do?” [9]
Medium tests are usually automated and involve two or more interacting features. The focus is on testing the interaction between features that call each other or interact directly. [10] Software engineers drive the development of these tests early in the product cycle as individual features are completed and developers are heavily involved in writing, debugging, and maintaining the actual tests. If a medium test fails or breaks, the developer takes care of it autonomously. The question a medium test attempts to answer is, “Does a set of near adjacent functions operate with each other the way they are supposed to?” [11]
Large tests cover three or more features and represent real user scenarios with real user data sources. There is some concern with overall integration of the features, but large tests tend to be more results-driven, checking that the software satisfies user needs. All three roles are involved in writing large tests and everything from automation to exploratory testing can be the vehicle to accomplish them. The question a large test attempts to answer is, “Does the product operate the way a user would expect and produce the desired results?”