Search code examples
junitjmock

How to test a void method with JMock


How to test a void method i.e. method that doesn't return anything in JMock?


Solution

  • To test a method that doesn't return anything, regardless of the testing or mocking framework you're using, you test the effect of a call to the method.

    With JMock that likely means that you create a mock of something the code you're testing should call, set things up so that your mock is used instead of a real object, and set and verify expectations for calls to that mock.

    I might be able to get more specific if you can add specifics to your question.