2.4 Summary


2.4 Summary

This chapter focuses on the reasons why unit test automation is necessary and how automated unit tests can be realized. While Section 2.2 formulated a few requirements to an automation framework, Section 2.3 showed how they can be implemented in JUnit:

  • Programming language equals test language. JUnit is a pure Java framework.

  • Separation of application and test code. Test cases are created in a separate class hierarchy, using the junit.framework.TestCase—base class.

  • Independence between test cases. JUnit allows us to move the common features of tests to a setUp() method, which is executed separately for each test. This means that we do not have to worry about the test order.

  • Arbitrary grouping of tests into test suites. The concept of a suite is available in the junit.framework.TestSuite class.

  • Test results are visible at a glance. Assert methods serve for unique verification of the test results. Graphical test runners show successful test runs in green and failed test runs in red.

For these reasons, JUnit is ideally suited for use as an automation tool to automate developer-side component tests. Because it is freeware, we have used it as a basis for most of the code examples in this book.

In this chapter we discussed the technical aspects of the creation and execution of test cases in JUnit. The rest of this book will deal mainly with the creation of "the right" test cases. The word right relates to the creation time, quantity, size, structure, organization, and implementation. As in most aspects of our lives, we will see here too that there are no absolute rules and that we will have to give up looking for an optimal solution and instead settle for a sufficiently good solution.




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