Saying Hello to Mockito
Ever since the original publication of The C Programming Language[2] by Kernighan and Richie (1978), every programming language and framework is required, by law, to include a Hello, World! example. We’ll look at the Mockito version in this section, explain what Mockito does and what it is for, and introduce part of a larger system that we’ll use for further discussions later in the book.
For Java, the classic Hello, World! program is this, of course:
| public class HelloWorld { |
| public static void main(String[] args) { |
| System.out.println("Hello, World!"); |
| } |
| } |
The HelloWorld class contains a main method, but main returns void, and void methods are tough to test. Mockito is a testing library, ...
Get Mockito Made Clear now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.