Test-driven development (TDD) in Java

Audience

Architect, Programmer, Team lead

Duration

1 day

Overview

Unit test driven development (TDD) is one of the great development process innovations. While associated with Agile development, TDD can be applied to other, more traditional methodologies as well, bringing the same benefits:

  • very high level of automated unit test coverage;
  • programming activities remain goal-directed (the goals being encoded in tests);
  • ensure that each step is a step forward rather than back;
  • manage solution complexity by implementing simpler intermediate solutions before tackling more complex cases;
  • develop better quality component interfaces by driving interface development from a client’s perspective rather than the implementers perspective;
  • make code inherently unit testable;
  • manage dependencies better—making code easier to maintain.

Prerequisites

The course illustrates the theory and practice of unit test driven development. It is suitable for software developers with moderate programming experience. Deep technical knowledge is not required, so it is suitable for people with previous but not current programming experience.

Format

The course blends tutorial, class discussion, question and answer sessions, and demonstrations / simulations. Participants will be expected to follow along with examples on their own PCs but an element of teaching effective use of the development environment is included in the course so this should not require much previous experience.

Outline

Automated testing with JUnit

  • Learn the basic elements of automated unit testing
  • Basic elements of the Junit test framework
  • Junit integration with the integrated development environment (IDE)
  • Writing unit tests after code

Writing tests before code

  • Exploration of the problems test-after may create
  • Justifying writing tests before code (TDD)
  • The TDD process, using worked examples

Exercise

  • writing further unit tests and code for the example problem

Testing complex systems, stubs and mock objects

  • Explore the problem of testing large / deep graphs of connected objects, leading to stubs
  • Example: writing test code using stubs
  • Automated stub generation: mock objects

Exercise

  • writing mock object-based tests

Dependency management, style and best practices

  • Dependency management techniques and consequences for testing
  • Working “front to back”, chaining requirements and interfaces

Options

Not quite what you want? Contact us if you’d like to shorten or lengthen this course, aim it at a different audience, cover particular topics or combine it with our other courses, briefings or services.

Further information and booking

Please contact us for further information or to book this course.