First Technology Transfer

Standard and Advanced Technical Training, Consultancy and Mentoring

CourseCourse JAV104 Java Unit Testing

Duration: 2 Days

Intended Audience

The course is aimed at

  • Java developers
  • Quality-assurance engineers
  • Project managers
Students are expected to have a reasonable understanding of Java technology. Some familiarity with testing concepts (e.g. unit, integration, functional, and load testing) would be helpful.

Synopsis

This course provides an introduction to the philosophy and ethos of Unit Testing and now, in the case of Java development, it is realised via the JUnit testing framework. It describes the procedures for setting up JUnit and using it in Java development, and also integration of JUnit into the Eclipse Java Integrated Development Environment (IDE). Familiarisation with JUnit based unit testing is accomplished via a series of hands on exercises.

Course Objectives

By the end of the course student should know

  • How JUnit function in Java testing
  • How to integrate JUnit into the Java application development process
  • Implement procedures and guidelines regarding the design and implementation of unit testing
  • Appreciate the role of JUnit in the wider context of software quality control

Course Outline

  • Overview of Unit Testing and JUnit
    • Unit testing - concepts and philosophy
    • Overview of Unit Testing frameworks
    • Introduction to JUnit
    • Using JUnit within Eclipse
    • Structuring Unit Tests
    • JUnit Asserts
    • JUnit Test Composition
    • Custom Asserts
    • JUnit Exceptions and exception testing
    • Naming
    • Structure of the JUnit Test Skeleton
  • Right BICEP - What to test for ?
    • Right results
    • Boundary Conditions - CORRECT
      • Conformance
      • Ordering
      • Range
      • Reference
      • Existence
      • Cardinality
      • Time
    • Inverse Relationships - checking for
    • Cross checking
    • Error conditions - forcing of
    • Preformance characteristics - met
  • Structuring tests, automating tests, reporting results
    • Composing Test Cases into Test Suites
    • Combining Test Suites
    • Organizing Tests and Test Suites
    • Executing Tests
    • Displaying and recording Test Results
    • Integration with Ant and Maven
    • Reporting results in XML/HTML format
  • JUnit Extensions
    • Survey of JUnit Extensions: dbUnit, sqlUnit, httpUnit, htmlUnit, EasyMock, xmlUnit ...
    • Testing with Stubs
    • Mock Objects
    • Testing a Servlet
    • Testing with Mocks with EasyMock
  • Test-Driven Development (TDD)
    • Best Practices with JUnit and TDD
    • Designing Java code with testing in mind
    • Integration and functional testing using JUnit
  • Attributes of Good Tests
    • Automatic
    • Thorough
    • Repeatable
    • Independent
    • Professional
    • Support Quality control
  • Testing and Design
    • Designing for testability
    • Refactoring for Testing
    • Defining and verifying Class Invariants
    • Test Driven Design Strategies
    • Testing for Invalid Parameters
  • Integarating Unit Testing with Project Planning and Management
    • Where to place the test code
    • Testing etiquette
    • Frequency of testing
    • Testing when working with legacy code
    • Testing and Code Reviews (Structure Walkthroughs)