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?

Answers


I would split up the tests

  1. Test if the event is fired
  2. 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)


Need Your Help

Azure website disable FREB in deployment slots

azure azure-web-sites

I'm trying to clean up my Event logs which show lots of identical errors

Restore previous actor state after exception

scala akka actor

I have an actor which receive Int and accumulate result to the buffer. Some times actor can throw exception. What is the best way to restore previous state of buffer into actor after exception ?