- Shopping Bag ( 0 items )
Mockito is a testing framework that creates external dependencies (which is called mocking) which is used to test/simulate the behavioral patterns of the software and generate reports about it. Frameworks like Mockito fake or “mock” the external dependencies so that the object being tested has a consistent interaction with the outside dependencies. Mockito streamlines the delivery of the external dependencies that are not subjects of the test. Why Mockito? Compared to ...
Mockito is a testing framework that creates external dependencies (which is called mocking) which is used to test/simulate the behavioral patterns of the software and generate reports about it. Frameworks like Mockito fake or “mock” the external dependencies so that the object being tested has a consistent interaction with the outside dependencies. Mockito streamlines the delivery of the external dependencies that are not subjects of the test. Why Mockito? Compared to its main Java competitors EasyMock and jMock, Mockito, it is the most widely used mocking framework.
This book consists of recipes that depict the usage of a vast majority of Mockito functionalities in real-life examples. It goes beyond the documentation and covers how Mockito works and shows the steps to write effective tests using Mockito. It begins with getting to know the Mockito configuration, then you will learn how to create mocks and stubs, and afterwards you will be shown how to write good tests using Mockito together with how to properly stub behavior of your test objects. We'll finish by showing you some of the most interesting Mockito extension-based tools together with a comparison of the most widely used mocking frameworks.
This is a focused guide with lots of practical recipes with presentations of business issues and presentation of the whole test of the system. This book shows the use of Mockito's popular unit testing frameworks such as JUnit, PowerMock, TestNG, and so on.
Who this book is for
If you are a software developer with no testing experience (especially with Mockito) and you want to start using Mockito in the most efficient way then this book is for you. This book assumes that you have a good knowledge level and understanding of Java-based unit testing frameworks.
Posted July 26, 2014
One nice thing about Mockito is that its name actually makes [some] sense, instead of the random whimsical nomenclature adopted by many other packages. Mockito also addresses a real need to test your software. It offers a systematic approach, instead of the common ad hoc approaches devised earlier.
Like having easy test stubs that simulate method calls with hardwired expected correct results, in lieu of the method actually doing what it is meant to do.
Loose coupling is the hallmark of Mockito. That a deliberate minimal connection between the test code and the production code leads to easier testing. Otherwise when you change the production code, a concomitant change in the test code is needed. Which of course slows things down. As well, since any code is liable to bugs, updating test code can certainly put bugs into them. So if the buggy test harness says the production code is wrong, when it is the latter that is actually correct, this leads to circular debugging.
The code snippets in the book are for Java. Heavy use is made of JUnit. Sensible, since it was explicitly for unit testing.
Mockit also offers partial mocks. [Great terminology!] For the real word case when you have some new code base, written to solid techniques. But it integrates with a legacy code base or third pary libraries of uncertain calibre. I imagine partial mocks will be the most useful section of the book to some readers in this pickle.
Much of Mockito can be understood as you writing tests that define what should happen, and not how. The latter is the duty of production code. In this sense, Mockito simply recaps what has long been known in large software projects, and certainly this predates the very existence of Java.