Mockito

Mockito is a mocking framework with a clean and simple API. Tests produced with Mockito are readable, easy to write, and intuitive. It contains three major static methods:

  • mock(): This is used to create mocks. Optionally, we can specify how those mocks behave with when() and given().
  • spy(): This can be used for partial mocking. Spied objects invoke real methods unless we specify otherwise. As with mock(), behavior can be set for every public or protected method (excluding static). The major difference is that mock() creates a fake of the whole object, while spy() uses the real object.
  • verify(): This is used to check whether methods were called with given arguments. It is a form of assert.

We'll go deeper into Mockito once we start coding our Tic-Tac-Toe v2 application. First, however, let us quickly go through a new set of requirements.

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

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