The JMockit Testing Toolkit Tutorial
-
Introduction
- Automated developer testing and test isolation
- Testing with mock objects
- An example
- Running tests with JMockit
-
Testing enterprise applications
- An example
- Interface resolution
- Trade-offs of the approach
-
Mocking
- Mocked types and instances
- Expectations
- The record-replay-verify model
- Instantiation and injection of tested classes
- Recording results for an expectation
- Flexible matching of argument values
- Specifying invocation count constraints
- Explicit verification
- Delegates: specifying custom results
- Capturing invocation arguments for verification
- Cascading mocks
- Matching invocations to specific instances
- Partial mocking
- Mocking unspecified implementation classes
-
Faking
- Fake methods and fake classes
- Applying fake classes
- Faking unspecified implementation classes
- Faking class initializers
- Accessing the invocation context
- Proceeding into the real implementation
- Reusing fakes between tests
- Global fakes
- Applying AOP-style advice
-
Measuring code coverage
- The coverage metric
- Types of coverage output
- Configuring the coverage tool
- Aggregated reports for multiple test runs
- Checking minimum coverage
- Activating coverage in a Maven project
- Turning coverage off