The JMockit Testing Toolkit Tutorial
-
Introduction
- Developer testing and test isolation
- Testing with mock objects
- Tools for testing with mock objects
- Issues with conventional mock objects
- An example
- Running tests with JMockit
-
Mocking
- Mocked types and instances
- Expectations
- The record-replay-verify model
- Regular, strict, and non-strict expectations
- Recording results for an expectation
- Matching invocations to specific instances
- Flexible matching of argument values
- Specifying invocation count constraints
- Explicit verification
- Capturing invocation arguments for verification
- Delegates: specifying custom results
- Cascading mocks
- Accessing private members
- Partial mocking
- Capturing implementation classes and instances
- Instantiation and injection of tested classes
- Reusing expectation and verification blocks
- Other topics
-
Faking
- Mock methods and mock classes
- Setting up mocks for a test
- Mocking interfaces
- Mocking unspecified implementation classes
- Invocation count constraints
- Mocking class initializers
- Accessing the invocation context
- Proceeding into the real implementation
- Reusing mocks between tests
- Mock-ups at the test class/suite level
-
Reflection-based utilities
-
Measuring code coverage
- Line coverage
- Path coverage
- Data coverage
- 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 output off
- Standalone mode
-
Testing enterprise applications
- Scenario-based testing
- An example