Using gTest in UI application

1,522 views
Skip to first unread message

Ranjit

unread,
Nov 12, 2008, 7:28:49 AM11/12/08
to Google C++ Testing Framework
Hi All,

I am working in Qt 4.4 application development and want to use gTest
in TDD process.

I am not getting idea how to use gTest for UI based Qt application.

I tried having one console application project to run all test case
using gTest and one UI application to write all test case for
production code which is UI intensive and one production project which
is exe.

Can thrown light on these? Is my approach correct?

Regards,
Ranjit

Keith Ray

unread,
Nov 12, 2008, 11:54:02 AM11/12/08
to Ranjit, Google C++ Testing Framework
What I've done in the past (native GUI apps, not Qt, not using gTest)...

A. The project file has multiple Debug targets. One target is a
console application that runs all the tests; the "release" target is
GUI application that doesn't run tests. Most of the UI code was
untested. Encourages "thin" GUI.

B. The project file has one Debug target which is a GUI application.
When the app runs, the user can select a menu item to run the unit
tests. There are some difficulties when portions of application /UI
state is global (e.g. there is only one Application object, killing
that object kills the app.)

C. The project file has a GUI application target, but all the unit
tests are run before the UI starts waiting for user input. Similar
problems as B.

You'll have to experiment. Perhaps you can have multiple test apps,
each using gTest, and you have a python script that runs them. Each
test app can bring up the GUI, test something, and quit without
waiting for user input. This will probably be rather slow, so I would
suggest grouping all non-GUI tests into a single app for speed.

--
C. Keith Ray, IXP Coach, Industrial Logic, Inc.
http://industriallogic.com 866-540-8336 (toll free)
Groove with our Agile Greatest Hits: http://www.industriallogic.com/elearning/
http://agilesolutionspace.blogspot.com/

Keith Ray

unread,
Nov 12, 2008, 4:19:52 PM11/12/08
to Ranjit, Google C++ Testing Framework
You might ask on the TDD mailing list - some members of that yahoo
group have experience with TDD and GUI applications.

http://tech.groups.yahoo.com/group/testdrivendevelopment/

yop

unread,
Nov 13, 2008, 4:16:01 AM11/13/08
to Google C++ Testing Framework

On Nov 12, 2:28 pm, Ranjit <ranjit2...@gmail.com> wrote:
> Hi All,
>
> I am working in Qt 4.4 application development and want to use gTest
> in TDD process.

Me too with a Qt 3.x application. There was some discussion after an
equivalent question I posted at stackoverflow (
http://stackoverflow.com/questions/239453/approaches-to-creating-the-view-for-humble-dialogs
). This approach makes the dependencies to the UI framework as few as
possible but has problems in larger more complex UIs. You can refer to
http://martinfowler.com/eaaDev/uiArchs.html for an overview of
approaches for creating a gui.

My current approach is:
* Use gtest for all business logic. I have a very thin UI layer on top
of it.
* If I need tests on the UI I use QtTest that is bundled with your Qt
4.x libraries. It is not even near to what you can do with gtest but
is exactly what you need to test UIs written with Qt.

HTH,
Yorgos
Reply all
Reply to author
Forward
0 new messages