Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit testing - 2 #31

Open
egandunning opened this issue Feb 9, 2017 · 1 comment
Open

Unit testing - 2 #31

egandunning opened this issue Feb 9, 2017 · 1 comment

Comments

@egandunning
Copy link
Owner

Use QtTest framework.

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

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

@Quintonamore
Copy link
Collaborator

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.

@Quintonamore Quintonamore changed the title Unit testing Unit testing - 2 Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants