How To Take This Class

Course Overview

Mastering Test Driven Development using JUnit is a four-day, comprehensive hands-on test-driven development / JUnit / TDD training course geared for developers who need to get up and running with essential Test-driven development programming skills using JUnit and various open-source testing frameworks. Throughout the course students learn the best practices for writing great programs in Java, using test-driven development techniques. This comprehensive course also covers essential TDD topics and skills.

Course Prerequisites

Attendees should be familiar with Java and object-oriented technologies. Real world programming experience is a must.

Course Audience

This is an intermediate-to-advanced level Java course, designed for developers who wish to get up and running on test-driven development immediately.

What You'll Learn

Upon successful completion of this course, students will be able to:
  • Understand JUnit
  • Understand and use the JUnit Test Runner interface
  • Use JUnit to drive the implementation of Java code
  • Test applications using native IDE support
  • Best practices and patterns for test development
  • Understand JUnit’s strengths and weaknesses
  • Understand the role of debugging when done in conjunction with tests
  • Understand not only the fundamentals of the TDD using Java, but also its importance, uses, strengths and weaknesses
  • Understand the basics of JUnit, Cactus and other testing frameworks and how they relate to TDD
  • Learn to better control the development and quality of Java code
  • Understand how JUnit affects your perspective on development and increases your focus on a task
  • Learn good JUnit coding style
  • Create well structured JUnit programs
  • Compile and execute programs using JUnit, Cactus, StrutsTestCase and DBUnit using the IDE of your choice
  • Understand how JUnit testing can be used for either state-based or interaction-based testing
  • How to extend testing with mock objects using EasyMock
  • Look at refactoring techniques available to make code as reusable/robust as possible
  • Discuss various testing techniques

Course Duration

4 Days

Course Outline

  1. Test-Driven Development
    • Overview of Test-driven Development
    • The Problem
    • What is Unit Testing?
    • Purpose of Unit Testing
    • Successful Unit Testing
    • JUnit Overview
    • Reasons to Use JUnit
    • How JUnit works
    • Creating a TestCase
    • JUnit Methods to Override
    • Introducing Class Message
    • Creating Class MessageTest
    • The First Test Implementation Steps
    • The Initial Test Code
    • Testing the Constructor
    • Running a Test
    • Seeing the Results of a Test : JUnit View
    • Using the Results of a Test
    • Seeing the Results of a Successful Test
    • Defining a TestSuite
    • An Example TestSuite
    • Test, code, refactor, repeat
    • Rationale for Test-driven Development
    • The Process of TDD
    • Advantages to TDD
    • Side-effects of TDD
    • Observations About Tests
    • Tools to support TDD
    • Automation and Coverage
    • Working With Coverage Analysis
    • Rationale
    • Advantages
    • Tools
  2. Testing Frameworks
    • Integration Testing: jWebUnit/HttpUnit
    • Presentation testing
    • Integration testing
    • jWebUnit
    • jWebUnit/HttpUnit
    • Testing Struts: StrutsTestCase
    • Design of a Struts application
    • StrutsTestCase
    • Testing strategies
  3. TDD Tools and Techniques
    • Mock Objects and EasyMock
    • Decoupling with Mock Objects
    • Mock object frameworks
    • EasyMock and JUnit
    • Dependency Injection, Spring and Testing
    • Dependency Injection and IoC
    • The Spring Framework
    • Mock Objects and Spring
    • State-based vs. Interaction-based Testing
    • State-based testing
    • Interaction-based testing
    • Dependencies vs. mock objects
    • Interaction-based Testing
    • JUnit and Ant
    • Running JUnit Tests from Ant
    • Generating a JUnitReport
  4. Improving Code Quality Through Refactoring
    • Refactoring Overview
    • Sample of Refactorings
    • Refactoring and Testing
    • Suggested Refactoring
    • The Impact of Refactoring
  5. Additional Testing Frameworks
    • Database Testing: DBUnit
    • Issues related to database testing
    • Persistence mechanisms
    • DBUnit
  6. TDD and Spring (optional)
    • The Spring Framework
    • Spring Basics
    • Configuring a Spring bean
    • Property Editors
    • Constructor injection vs. Setter injection
    • Wiring the collaborators
  7. Advanced TDD Topics (optional)
    • Design Patterns
    • Code That Feels Wrong
    • Refactoring to Design Patterns
    • Abstract Factory Design Patterns
    • Sample Refactorings
    • Adapter Design Patterns
    • Sample Refactorings
    • Strategy Design Patterns
    • Sample Refactorings
    • Testing Business Rules
    • Adding Testing to Your Build Process
    • The Ant JUnit Tag
    • Example Ant Build File
    • Continuous Integration
  8. Additional Testing Frameworks
    • Server-side Testing: Cactus
    • Server-side testing
    • Cactus: mock-container testing
    • Cactus: in-container testing