9.6 Summary


9.6 Summary

Persistence plays an important role in most programs. The creation of unit tests for persistence mechanisms is often accompanied by major problems, because both the execution speed and the large number of dependencies make the naive testing approach difficult.

Hiding the persistence layer behind an abstract interface allows us to separate the higher-layer tests from a concrete implementation and thus from a database. This simplifies our test cases and accelerates their execution by several orders of magnitude. Use of the real implementation normally verifies only the methods specified in the persistence interface, which should be kept as small as possible. In addition, we should always strive for the simplest persistence technology within the context of a specific project.

Mock objects can be used to test an implementation built on JDBC, but often require too much work to be worthwhile. A few interaction tests between the persistence mechanism and higher-level objects are meaningful to ensure a basically functioning communication.




Unit Testing in Java. How Tests Drive the Code
Unit Testing in Java: How Tests Drive the Code (The Morgan Kaufmann Series in Software Engineering and Programming)
ISBN: 1558608680
EAN: 2147483647
Year: 2003
Pages: 144
Authors: Johannes Link

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net