Reputation: 5341
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?
Upvotes: 0
Views: 464
Reputation: 17489
I would split up the tests
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)
Upvotes: 1