Test-Driven Development in Java – Unit Testing and Refactoring for Agile Software Development

Request info

Agile Software Development Training

Overview

The Test-Driven Development in Java course presents a number of modern practices for developing code based on an iterative and incremental development lifecycle. Agility and predictability are two qualities often missing from software development. A test-driven approach, in which design is grown and code delivered incrementally according to functionality or risk, forms the basis of the construction phase of an iterative and incremental development. The use of unit testing provides confidence in existing code and supports the ability to refactor code as development unfolds. The course is intended as a practical course: the best way to appreciate how test-driven development works and what it feels like is to do it in practice, making sense of the principles it embodies. In this form the course is based on lecture material, demonstration, discussion and hands-on labs. However, the course can also be run as a seminar without hands-on labs, which puts more emphasis on understanding the principles through the demonstrations.

Layout

The training course combines lectures with practical exercises that help the delegates to put what they have learned on the training course into practice. The exercises specifically build on what has been recently taught and are built up as the training course progresses.

Who it is for

The course is suitable for software developers experienced in Java and familiar with objectoriented principles and practices.

Training Course Prerequisites

Any previous exposure to JUnit or agile development concepts is beneficial but not essential.

Training Course Objectives

At the end of this training course, students should be able to:

Appreciate the benefits of a continuous and iterative approach to design and delivery
Recognise the purpose and practice of refactoring in keeping a system supple and adaptable
Know how to build up a set of unit tests in JUnit
Understand the consequences of dependency management on testing and code quality

Training Course Contents

1. Agile Development Microprocess

Traditional versus agile development processes
Iterative and incremental development
Informal and continuous design
The role of refactoring
Refactoring versus other code changes
Extreme Programming
Test-Driven Development

2. Testing in Principle

Traditional view and reality of testing
Driving development through testing
Testing early, often and automatically
Testing versus debugging
White-box versus black-box testing
Functional versus operational testing

3. Basic Unit Testing in Practice

Test plans versus test code
Use of Assert
Testing at the interface
Testing the simplest things first
Testing incrementally
Testing correctness of failure

4. Overview of JUnit

JUnit and the xUnit family
Test cases, test suites and test runners
Essential structure of the framework
Assertion methods
Testing correctness of exceptions
Defining common fixture code
JUnit pattern usage
Extensions to JUnit

5. Test-Writing Techniques

Red, green, refactor
None to one to many
Faking it
Telling the truth
Isolated and short tests
Refactor common fixture code
Declare, prepare, assert
Test by method, state or scenario
Custom assertions
Compile-time constraints
Running all tests

6. Common Refactorings

Renaming variables, methods, classes and packages
Restructuring class hierarchies by extracting interfaces, superclasses and subclasses
Partitioning classes by extracting classes and methods
Changing private representation

7. Decoupling Techniques

Unmanaged dependencies
Test-driven decoupling
Layering
Reorganising packages
Eliminating cyclic dependencies
Mock objects
Eliminating Singletons, statics and other globals
Testing I/O

Course duration: 2 Days

Agile Software Development training Inverness, Aberdeen, Glasgow, Edinburgh, Dunfermline and other sites throughout the UK including onsite closed company courses are available.

Agile Software Development training in Ghana, Nigeria and Qatar is also available.

SELECT wp_posts.*, wp_p2p.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) INNER JOIN wp_p2p WHERE 1=1 AND ( ( wp_postmeta.meta_key = 'start_date' AND CAST(wp_postmeta.meta_value AS DATE) >= '2024-12-14' ) ) AND ((wp_posts.post_type = 'schedule' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled'))) AND (wp_p2p.p2p_type = 'schedule_to_courses' AND wp_posts.ID = wp_p2p.p2p_from AND wp_p2p.p2p_to IN (SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.ID IN (941) AND ((wp_posts.post_type = 'courses' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled'))) ORDER BY wp_posts.post_date DESC )) GROUP BY wp_posts.ID ORDER BY CAST(wp_postmeta.meta_value AS DATE) ASC