JUnit: A Hands-On Introduction
Please turn off all
Getting to Know Each Other
Different Kinds of Tests
Different Styles of Testing
When To Write the Tests
Or
Why write automated tests?
Micro Test Driven Development
Everything is preceded by a test
JUnit
A class to develop: The Fraction Class
Basic operations the class needs
Big Question
Java utilities the class needs
Test Classes
Demo: A simple test for addition
The Result: A simple Fraction class
What's wrong with this?
Another Test
Some Tests Pass the First Time You Run Them
We need to test equals failing
Plausible class
Exercise 1: Compile and run the simple addition test
What else do we need to test?
Exercise 2: Expanding the test suite
Answer 2: Expanding the test suite
Macro Test Driven Development
Benefits of Test Driven Development
For Unit Testing to Work
Test Driven Testing
Unit Testing
Reinitialization Example
Consequences
static data is not reinitialized
Fixtures
Exercise 3: Adding a Fixture
Answer 3: Adding a Fixture
Freeing resources after each test
Constructors for TestCase
Exercise 4: Adding a Constructor
Answer 4: Adding a Constructor
Assertion Messages
Exercise 5: Messages
Answer 5: Assertion Messages
Floating point assertions
Exercise 6: Floating point test
Answer 6: Floating point test
Integer assertions
Exercise 7: Integer test
Answer 7: Integer test
Integration Tests
Exercise 8: Data Driven TestCase
Answer 8: Data Driven Test
Data Driven Test Issues
Answer 8 Improved: Data Driven Test
Parameterized TestCase Pattern
Parameterized TestCase Example
Autogeneration of Tests
Round Trip Tests
Exercise 9: Randomized Tests
Answer 9: Data Driven Test
Object comparisons: asserting object equality
Object comparisons: asserting object identity
Asserting Truth
Asserting Falsity
Asserting Nullness
Asserting Non-Nullness
Deliberately failing a test
Tests that throw Exceptions
Testing exceptional conditions
Exercise 10: Exploring an API through Tests
Answer 10: Testing Exceptional Conditions
Testing Files
Faking Input
Testing Output
Exercise 11: Serialization
Answer 11: Testing I/O
Test Suites
Test Suites
Test Suites
Test Suites Can Be Combined Into Larger Suites
Testing Fields
Testing Protected Methods
Testing Abstract Classes
Testing Package Protected Methods
Testing Private Methods
Testing Interfaces
What to Test
What Not to Test
TestRunners
Main method for TestCase
Exercise 12: Adding a main method
Answer 12: Adding a main method
TestListeners
Writing Your Own TestListener
Writing Your Own TestRunner
Integrating Tests into the Build Process
Ant
Ant Reports
Maven
Excluding Tests from the JavaDoc
Test Suite Performance
Profiling tests
Unnecessary Initialization
Measuring Test Coverage
Testing Databases
Testing Web Servers and Services
To Learn More
Questions?
Entire Presentation as Single File
Start
|
Cafe con Leche
Copyright 2005-2007 Elliotte Rusty Harold
Last Modified January 28, 2007