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?
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
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.