Can I and Should I test fireEvent and Handlers method in GWT?
I am writting test for GWT, but I did not find any example of fireEvent test. Can any one help me?
I have event that has handler which put some current variable on the list. I would like to test the method that fires an event?
Does this make any sense to anyone?
Do we need such Unit tests?
I would split up the tests
- Test if the event is fired
- Test the method that puts a variable on a list by just calling the method directly
Regarding 1: You can use com.google.gwt.event.shared.testing.CountingEventBus and then use getCount(GwtEvent.Type) to check how many times the event was fired, see here for more infos. If you pass data in your event object and you want to test that you can create your own fake EventBus (see this and this test for more infos)
You can also test that the your handler is properly executed when you fire the event. Just fire the event on the EventBus and use an assertion for the list (see this test for an example)