#QSpec [] (https://travis-ci.org/ugeneunipro/QSpec)
QSpec
is a GUI testing library for Qt desktop applications.
You need create declarations for tests like follow:
#include <core/GUITest.h>
#define GUI_TEST_SUITE "My_base_tests"
TEST_CLASS_DECLARATION(Test1)
TEST_CLASS_DECLARATION(Test2)
#undef GUI_TEST_SUITE
Also need create definitions of tests:
TEST_CLASS_DEFINITION(Test1){
//body of test
}
TEST_CLASS_DEFINITION(Test2){
//body of test
}
After this you need implement GUITestsLauncher
:
#include <core/GUITestsLauncher.h>
class MyGUITestsLauncher: public GUITestsLauncher
{
public:
MyGUITestsLauncher();
};
MyGUITestsLauncher::MyGUITestsLauncher(): GUITestsLauncher()
{
guiTestBase.registerTest(new Test1());
guiTestBase.registerTest(new Test2());
}
In main function of your application you need add something like this:
QString runGuiTest = qgetenv("HI_GUI_TEST");
if (!runGuiTest.isEmpty()) {
MyGUITestsLauncher* tests = new MyGUITestsLauncher();
tests->connect(&myMainWindow,SIGNAL(si_applicationStarted()),tests,SLOT(sl_runTest()));
}
A single test can be run just using environment variable 'HI_GUI_TEST'. For Unix systems:
export HI_GUI_TEST=<suite_name>:<test_name>
or for Windows systems:
set HI_GUI_TEST=<suite_name>:<test_name>
And then execute you application.
Qt5
- Linux:
- X11 Record extension library (sudo apt-get install libxtst-dev)
This project available under GNU GPL V2.