aspose file tools*
The moose likes Testing and the fly likes Testing the UI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Testing the UI" Watch "Testing the UI" New topic
Author

Testing the UI

S Saunders
Greenhorn

Joined: Mar 21, 2003
Posts: 22
My team this year decided to experiment with unit testing. I found it to be quite helpful during our development. However some of my tasks dealt mostly with the creation of the user interface. I found that I had a difficult time creating JUnit tests for this. In fact, we decided to not write tests that dealt with the UI. Could those who have had experience with this eloborate on the following questions.
What are the possibilities for testing?
Is it possible to use JUnit for these tests?
And finally,
Should I go to the trouble of creating the Java event objects to use in my tests?
Thanks,
Steve
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30299
    
150

Steve,
Do you use an AWT/Swing UI or an HTML/JSP UI?
If it is an AWT/Swing UI, you can test the underlying model. There are probably ways of testing the actual UI, but I'm not sure what they are.
If it is an HTML/JSP UI, you can use Mock Objects and JWebUnit to test the session/request objects and layout.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
S Saunders
Greenhorn

Joined: Mar 21, 2003
Posts: 22
We use an AWT/Swing UI. You mentioned testing of the underlying model, what does this entail? I am new to testing and am trying to grasp the terminology and philosophies.
Steve
Originally posted by Jeanne Boyarsky:
Steve,
Do you use an AWT/Swing UI or an HTML/JSP UI?
If it is an AWT/Swing UI, you can test the underlying model. There are probably ways of testing the actual UI, but I'm not sure what they are.
If it is an HTML/JSP UI, you can use Mock Objects and JWebUnit to test the session/request objects and layout.
Vincent Massol
Author
Ranch Hand

Joined: Aug 09, 2003
Posts: 70
Originally posted by S Saunders:
My team this year decided to experiment with unit testing. I found it to be quite helpful during our development. However some of my tasks dealt mostly with the creation of the user interface. I found that I had a difficult time creating JUnit tests for this. In fact, we decided to not write tests that dealt with the UI. Could those who have had experience with this eloborate on the following questions.
What are the possibilities for testing?
Is it possible to use JUnit for these tests?
And finally,
Should I go to the trouble of creating the Java event objects to use in my tests?
Thanks,
Steve

You can have a look at http://www.junit.org/news/extension/gui/index.htm
I've tried Abbot and it's quite nice.


-Vincent<br /><a href="http://www.manning.com/massol" target="_blank" rel="nofollow">JUnit in Action</a> author
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30299
    
150

Steve,
Suppose you are displaying a table in a Swing program. You can check that the table has the correct values, number of rows/columns, ... While this doesn't check everything, it's better than nothing. I remember reading an article with a good example of this, but now I can't find it.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
There is also an entry in our FAQ: http://test.javaranch.com/wiki/view?UnitTestingGuis


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
S Saunders
Greenhorn

Joined: Mar 21, 2003
Posts: 22
Originally posted by Jeanne Boyarsky:
Steve,
Suppose you are displaying a table in a Swing program. You can check that the table has the correct values, number of rows/columns, ... While this doesn't check everything, it's better than nothing. I remember reading an article with a good example of this, but now I can't find it.

So you are suggesting a "traditional" test check of the UI components. I agree that this is important. I would be interested in the article if you remember or even if you remember the publication/website would be good.
Thanks,
Steve
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34


So you are suggesting a "traditional" test check of the UI components. I agree that this is important. I would be interested in the article if you remember or even if you remember the publication/website would be good.

You can also easily test all the event-handling code if you don't tie it tightly to the GUI components. For example, any non-trivial event handlers ought to look like this:

Where "handler" is a reference to a non-graphical object. Now the "complicated..." method can be tested isolated from the GUI itself.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Testing the UI