Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt, unit testing and mock objects

Qt framework has internal support for testing via QtTest package. Unfortunately, i didn't find any facilities in it that can assist in creating mock objects. Qt signals and slots offers a natural way to create a unit-testing friendly units with input (slots) and output (signals). But is it any easy way to test that calling specified slot in object will result in emitting correct signals with correct arguments? Of course i can manually create a mock objects and connect them to objects being tested, but it's a lot of code. Maybe it's some techniques exists that allows to somehow automate mock objects creation while unit-testing Qt-based applications?

like image 427
grigoryvp Avatar asked May 12 '10 11:05

grigoryvp


1 Answers

It seems that you need a QSignalSpy.

like image 185
chalup Avatar answered Oct 17 '22 23:10

chalup