[SOLVED] How do I unit testing my GUI program with Python and PyQt?

Issue

I heard Unit Testing is a great method to keep code working correctly.

The unit testing usually puts a simple input to a function, and check its simple output. But how do I test a UI?

My program is written in PyQt. Should I choose PyUnit, or Qt’s built-in QTest?

Solution

There’s a good tutorial about using Python’s unit testing framework with QTest here (old link that does not work anymore. From the WayBackMachine, the page is displayed here).

It isn’t about choosing one or the other. Instead, it’s about using them together. The purpose of QTest is only to simulate keystrokes, mouse clicks, and mouse movement. Python’s unit testing framework handles the rest (setup, teardown, launching tests, gathering results, etc.).

Answered By – WLin

Answer Checked By – Marie Seifert (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *