[TFUI] Re: User Interface Testing
"Phlip" <[email protected]>
| Newsgroups | gmane.comp.programming.test-first-user-interfaces |
|---|---|
| Message-ID | <008101c51373$40ca3e50$0102a8c0@DF619121> |
Richard Nienaber wrote:
> I'm sure this question must have come up before but here goes anyway.
> Our development team programs in Java and we just started using JUnit
> for the testing of the individual components. However, this stills
> leaves the problem of the UI. Is there any methodology I can use for
> testing the UI in a JUnit type of way or does this fall under user
> acceptance testing?
Treat a GUI control as "just another object". Create a form in a test, call
its methods to simulate clicking on it and simulate looking at it.
There are numerous pit traps and obstacles to doing this, so
_start_falling_in_them_. If you use the tests, and extra test-side code, to
get out, you will soon be able to TDD a GUI for long spells without ever
looking at it.
To facilitate this, write a method called reveal() that temporarily displays
windows, and write test cases that temporarily call it:
test_myForm()
myForm = Form.new()
myForm.myButton.click()
// reveal(myForm)
assert("green" == myForm.myLabel.getColor()
end
For most GUIs, if you never invoke their event queue, they never display,
but they process most of their inputs. That test case simulates clicking on
a button, and inspecting that a label is green. However, my hypothetical
click() method might not behave the same as a real user clicking, and my
getColor() method might have a bug. GUI Toolkit writers only care that users
can use their GUIs, not testers.
So if you decomment the reveal() method and run the tests, the window will
pop up in its tested state. You briefly inspect that click() and getButton()
are working. If they are not, you write new test-side functions that beef
them up.
Then you comment-out reveal(), and you use these test-side functions in
further test cases.
Shun like the devil GUI oriented test runners that use capture/playback. A
simple reveal() method, available to any test case at whim, can help your
test rig compete for your attention with your form painters and debuggers.
http://www.c2.com/cgi/wiki?TestFirstUserInterfacesPrinciples
--
Phlip
http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces
To unsubscribe, email:
TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/TestFirstUserInterfaces/
<*> To unsubscribe from this group, send an email to:
TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/