O'Reilly logo

Extreme Programming Installed by Chet Hendrickson, Ann Anderson, Ron Jeffries

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing for Looks

We have a properly connected panel. We can check the widgets'relative locations:

  • label left-of queryField

  • queryField left-of findButton

  • queryField above table

(Would we bother with these tests? Perhaps not, we might just put the panel on-screen and deal with its contents manually. There are times when such tests would definitely be appropriate, such as when we're working against a style guide or when the window format is expected to be stable.)

To make this test run, we need to put our panel in a frame or window. (Components don't have their screen locations set until their containing window is created.)

 public void testRelativePosition() { SearchPanel sp = new SearchPanel(); JFrame display = new JFrame("test"); display.getContentPane().add(sp); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required