tags:

views:

142

answers:

1

I've created a MenuItem and added an ActionListener using allProducts.addActionListener(this);

Is there a way to simulate the menu being clicked in a unit test?

A: 

Normally you should unit test the business method that your actionHandler executes. Because in a layered application, the handler should not do much, maybe just some nullchecking, and then delegate the event to a business method. So your test will execute this business method, and no "interaction" is needed to fire the event.

If you really want to test your GUI too (the code in the handler), you can try Selenium. It has a nice eclipse plugin too.

Michael Bavin