7 Replies - 477 Views - Last Post: 26 June 2013 - 10:04 AM Rate Topic: -----

#1 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1949
  • View blog
  • Posts: 4,048
  • Joined: 11-December 07

Automated Testing for GUI

Posted 19 June 2013 - 03:44 AM

I'm looking for a way to test my Java GUI. I can poke at bits of it with JUnit but those are the bits that should (or at least could) be refactored into non-gui classes.

I don't really want to write lots of code that uses Robot. That sounds tedious and I imagine the result would be fragile.

A google search turns up any number of websites with GUI testing tools. They are typically as bland as they are generic. One promising option looks like Cucumber but for all I know, there could be any number of excellent frameworks out there.

Before I pick one and dive in, does anyone have any advice for me? Have you used any before or have you had any recommendations in the past.

I nearly put this in the Software Development forum but it really is solutions for Java I want just now, although generic advice is also gratefully received.

Is This A Good Question/Topic? 0
  • +

Replies To: Automated Testing for GUI

#2 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2870
  • View blog
  • Posts: 11,025
  • Joined: 15-July 08

Re: Automated Testing for GUI

Posted 19 June 2013 - 06:16 AM

I would recommend using something that emulates user clicks and data entries without using the actual GUI. There's basically no difference whether a user invokes these methods or you do programatically, especially when doing integration testing. I've never done it with Swing, but fest looks really nice.

For most of my programs, I use robotium, but that's besically the same thing for Android.

Anyway, it looks like fest or cucumber might be good options for you.
Was This Post Helpful? 2
  • +
  • -

#3 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10443
  • View blog
  • Posts: 38,682
  • Joined: 27-December 08

Re: Automated Testing for GUI

Posted 19 June 2013 - 07:42 AM

I agree with Dogstopper. You can programatically do things like click JButtons (see the doClick() method), select elements in a JComboBox, etc. That should help with unit testing.
Was This Post Helpful? 1
  • +
  • -

#4 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1949
  • View blog
  • Posts: 4,048
  • Joined: 11-December 07

Re: Automated Testing for GUI

Posted 20 June 2013 - 01:28 AM

Fest looks pretty good. I'll give it a shot and see how I get on. If anyone else has recommendations for similar things they have used before that would be great too.

Quote

You can programatically do things like click JButtons (see the doClick() method), select elements in a JComboBox, etc. That should help with unit testing.


This is what I meant by "poke at bits of it". I've gone down this route before and it works well for some things but not at all for others. Persevering is a lesson in frustration.
Was This Post Helpful? 0
  • +
  • -

#5 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1949
  • View blog
  • Posts: 4,048
  • Joined: 11-December 07

Re: Automated Testing for GUI

Posted 25 June 2013 - 07:10 AM

Turns out fest-swing is exactly the tool I need. Thanks again for the recommendation!
Was This Post Helpful? 0
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Automated Testing for GUI

Posted 25 June 2013 - 08:22 PM

Seems to me that you are over-doing it
A GUI can be in a finite number of states
A GUI has a finite number of elements that can be clicked
Just make a table (using Excel) of what each clikable elemnt should produce based on the GUI state and check them
Not more complicated than that
Was This Post Helpful? 0
  • +
  • -

#7 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2870
  • View blog
  • Posts: 11,025
  • Joined: 15-July 08

Re: Automated Testing for GUI

Posted 25 June 2013 - 09:52 PM

View Postpbl, on 25 June 2013 - 11:22 PM, said:

Seems to me that you are over-doing it
A GUI can be in a finite number of states
A GUI has a finite number of elements that can be clicked
Just make a table (using Excel) of what each clikable elemnt should produce based on the GUI state and check them
Not more complicated than that


Normally, I'd agree with you. But when your GUI has 25+ screens, each with many variations on the input, it is easiest to do integration testing using a framework like Fest. In my last Android app, there were about 1500 test cases. Not exactly something I want to do by hand.

Another thing that is really nice about these frameworks is that when you "fix" something and the test works, it automatically runs every other test. So if by fixing one thing, you may inadvertently break something else. Having automated tests for these 1500 test cases rather than running each by hand after every single fix.
Was This Post Helpful? 2
  • +
  • -

#8 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1949
  • View blog
  • Posts: 4,048
  • Joined: 11-December 07

Re: Automated Testing for GUI

Posted 26 June 2013 - 10:04 AM

Dogstopper hit the nail on the head. It's easier to rerun a bunch of automated tests.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1