Neueda
Shape

Course

Test-Driven Development in Java

Test-driven development is one of the key enablers for agile development, that allows us to develop stable and refactorable code, whose intent is clear and whose design can evolve incrementally. TDD allows us to capture and validate the rules governing the behaviour of our code.
And… it’s also fun! There’s a bunch of interesting tools available to assist us in developing robust tests, in identifying which tests to write, to help us compose tests and to automatically run our tests.
The course is taught through presentation, demos, hands-on labs and directed discussions.

Duration: 2 days

Who is it for: This training course is aimed at Java developers and analysts, typically in the context of adopting agile development practices.

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.

Objectives

  • Use the JUnit and mocking libraries to write tests
  • Run tests from an IDE and from Maven/Gradle build scripts
  • Apply patterns and practices for writing testable code
  • Extend the scope of tests into analysis, design and documentation
  • Use tests to communicate with the customer

Modules

Introduction

  • Why test-driven development?
  • Is TDD necessary?
  • TDD is about…
  • red/green/refactor

Getting Started

  • Separating code from tests
  • Package structures
  • JUnit 4 basics
  • Assertions
  • JUnit setup/teardown
  • Exceptions

Writing Tests

  • Base test classes
  • Matchers
  • Naming / Organization
  • Implementation strategies
  • Exploring APIs
  • Parameterized test runners

Writing

  • Equals and value objects
  • Seams and sensing
  • Seam types
  • Inheritance
  • Singletons and Statics
  • Dependency injection

Test doubles

  • Test double taxonomy
  • Stubs
  • Fakes
  • Mocks
  • Mocking Libraries such as Mockito and PowerMock
  • Setting Expectations and Verifying Interactions
  • Mocking Gotchas
  • Testing Legacy Code

Understanding the Code through Tests

  • Showing the Call Hierarchy
  • Generating Documentation from Tests
  • Parsing the Test Source Code
  • Transcripts
  • Fluent Interfaces

Organising Tests

  • Test Suites
  • Explicitly-built Test Suites
  • Implicitly-built Test Suites
  • Filtering and Sorting
  • Ordering

TDD in Context

  • Relationship to Other Agile Practices
  • Closing Discussion

More on fixtures

  • Making the Context Concrete
  • One-time Setup for Classes
  • One-time Setup for Suites
  • Fixtures and Superclasses
  • Object Mothers
  • Fixtures as Objects
  • Data-driven Fixtures
  • Using Databases
  • Testing Database Code

Theories

  • Tests vs Theories
  • Triangulating Tests
  • Parameter Suppliers
  • Assumptions

Tests as Specification

  • The Trouble with TDD
  • Behaviour Driven Design using Cucumber
  • Customer Acceptance Testing using Cucumber and Selenium

Enquire about this course

"*" indicates required fields

By submitting this form, you agree to our Privacy Policy.
This field is for validation purposes and should be left unchanged.