egandunning / learn-crypto

PLU Computer Science Capstone project 2016-2017. A cryptography learning tool.
MIT License
2 stars 0 forks source link

Unit testing - 2 #31

Open egandunning opened 7 years ago

egandunning commented 7 years ago

Use QtTest framework.

http://doc.qt.io/qt-5/qttest-index.html

http://doc.qt.io/qt-5/qtest-overview.html

Quintonamore commented 7 years ago

I have created a Qt Unit testing project to add tests to. It has it's own pro file, to use it you can navigate to the test folder inside our project folder, use the .pro file to import the project and run tests from there. From there to make a new test copy this code into your .cpp file, and no header is necessary.

include <QtTest/QtTest>

class TestClass: public QObject { Q_OBJECT private slots: void findLetters(); };

void TestClass::findLetters(){ QString yo = "Yo"; QVERIFY(yo.toUpper() == "YO"); }

QTEST_MAIN(TestClass)

include "testclass.moc"

Notice that TestClass is the name of the .cpp file, and you should replace it with the name of your file. Be careful with the last include to make it all lowercase.