Other mock libraries

Apart from the stub implementation, there are many mocking frameworks available; you can use them to create unit tests. There are several mocking libraries available, such as Mockito, jMock, and EasyMock. You need to complete the following steps in order to perform tests with a Mock library:

  1. Use a mocking library to generate a mock object that implements the dependent interface on the fly
  2. Record the mock with expectations of how it will be used for a scenario
  3. Exercise the scenario
  4. Verify the mock expectations were met

The preceding mock considerations have the following benefits:

  • No additional class to maintain
  • You only need to set up what is necessary for the scenario you're testing

The only disadvantage is that these libraries are a little hard to understand at first.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.42.176