-
1. Re: How to mock addMessage
bleathem Sep 23, 2013 1:25 PM (in response to jbalaz)How would this approach be different from creating any other mock? Is there something special about mocking the FacesContext#addMessage method that's blocking you?
-
2. Re: How to mock addMessage
jbalaz Sep 23, 2013 2:48 PM (in response to jbalaz)Hi Brian maybe I badly named a topic.
what's my problem ... I created mock of FacesContext which returns MockFacesContext instance. when addMessage method is called nothing happens
because in the MockFacesContext is this method only stubbed and it is empty.
I tried to manage it by calling doCallRealMethod ... something like
doCallRealMethod().when( facesContext).addMessage( facesContext.getClientId("someId"), mockedMessage );
but this approach was unsuccessful
-
3. Re: How to mock addMessage
bleathem Sep 24, 2013 6:12 PM (in response to jbalaz)I can't tell you off-hand how to use mockito to mock the FacesContext add message - perhaps someone else will chime in.
However I can recommend that you test in a real container using Arquillian + Graphene/Warp. The RichFaces 5 "integration" tests are good examples of how to test in a real container. With modern/fast appservers and headless browsers like PhantomJS, these "real tests" can be quite reasonable to run both locally in your dev environment as well as in CI.
http://arquillian.org/guides/functional_testing_using_graphene/