I want to unit test a thread in my QT application, by checking that it emits the right SIGNALS when it receives a given set of SIGNALS.
I am executing my tests from main like this: (found here: What unit-testing framework should I use for Qt?)
TestClass1 test1;
QTest::qExec(&test1, argc, argv);
And my test look something like this:
void TestClass1::test_my_thread(){
MyThread my_thread();
my_thread.start();
QTest::qWait(2000);
my_thread.terminate();
}
Well, the idea is that I connect the threads slots to TestClass1, so I can send signals to it from my TestClass, and then use QSignalSpy to detect if the right signals are emitted from the thread. But allready when I try to create and run the thread it fails:
QFATAL : TestClass1::test_my_thread() Received signal 11
FAIL! : TestClass1::test_my_thread() Received a fatal error.
Loc: [Unknown file(0)]
Are my approach completly wrong? or what am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire