• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Testing the UI

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
S Saunders
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Author
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is also an entry in our FAQ: http://test.javaranch.com/wiki/view?UnitTestingGuis
 
S Saunders
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic