Radu D
Radu D

Reputation: 3555

Unittest GUI client

For my current project I develop a GUI that is used for configuring a server. The GUI is using some services to run commands.

Did you ever developed unit tests for a GUI client? Can you suggest me some architectural approaches in order to have my project unittestable?

Thanks, Radu

Upvotes: 0

Views: 155

Answers (4)

Gishu
Gishu

Reputation: 136663

I don't write unit tests for GUI clients. GUIs make my tests slow.

Instead split your client into a GUI skin on top of a set of classes. Search for PresentationModel or MVVM patterns for more information. Once you've done that, you can write (listed in decreasing order of speed and volume)

  • unit tests for the classes. (fast - microseconds per test)
  • Acceptance tests that operate the client like a real user but operate under-the-skin/GUI by exercising the presenters or the ViewModels (slower than unit tests)
  • a few sanity UI acceptance tests (that use a library like White) that verify that the GUI is hooked up to the underlying classes correctly. (slowest)

Upvotes: 1

yoosiba
yoosiba

Reputation: 2206

Hey.
For 'desktop' application use White to test GUI from unit test framework. For web app use Watin.

Upvotes: 1

treze
treze

Reputation: 3299

Besides the possibility of "gui-testing" your application with different tools that are developed for that, I would recommend using some passive view patterns like MVP for WinForms or MVVM(P) for WPF. By this way almost all intelligence is in the presenter, and by mocking away the view you can test it pretty well.

Upvotes: 1

pelya
pelya

Reputation: 4524

You may try libraries Dogtail for Linux or Pywinauto for Windows - the tests I've written with those libs looked like: Click that button, then watch if the server state changes as expected.

Upvotes: 1

Related Questions