Using the `TestInstancePostProcessor` Extension

Learn to use the `TestInstancePostProcessor` extension.

We'll cover the following

The TestInstanceProcessor extension allows the code to run after an instance of a test is created.

We have to create a class that extends the TestInstancePostProcessor interface. This allows us to write an extension that accesses the test instance post-processor extension point.

Use case

A commonly used extension for the test instance post-processor extension point is MockitoExtension. It injects mock objects into our unit test.

If we want to use a logger to log the debug or info statements inside our tests, we create a separate extension to inject the instance of the logger into our tests automatically.

Example

Get hands-on with 1200+ tech skills courses.