O'Reilly logo

Spring Persistence with Hibernate by Ahmad Seddighi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unit testing using mocks

With unit testing, as a rule, it is always necessary to test each object without relying on other application's objects which need testing as well. However, in many situations, the object being tested is tightly coupled with other objects. For example, the object being tested uses other objects to do its job. In such cases, mock objects help us to test the object conveniently without relying on other application's objects. Mock objects are also used in situations where testing an object needs to create other objects, such as connecting to a database, starting an application server, providing a socket object, and so on, that are costly. Mock objects work similarly to real objects, but we are sure about their operations ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required