Testing Utilities

GitLab Docs Pipeline Coverage
Various Utilities used in testing. This module contains a number of utilities and helpers to help with testing. It consists of a number of mostly independent parts.

See morimekta.net/utils for procedures on releases.

Getting Started

To add to maven: Add this line to pom.xml under dependencies:


To add to gradle: Add this line to the dependencies group in build.gradle:

testImplementation 'net.morimekta.utils:testing:5.3.0'
testImplementation 'net.morimekta.utils:testing-junit4:5.3.0'
testImplementation 'net.morimekta.utils:testing-junit5:5.3.0'


General testing utilities.

Concurrency Utils

  • FakeClock: A fake java.time.Clock that keeps constant time and is ticked manually.
  • FakeScheduledExecutor: A scheduled executor that uses a fake clock and 'ticking' of that to trigger scheduled tasks. Using a real executor in the background.
  • ImmediateExecutor: A fake executor that executes tasks when they are submitted. This means they run while waiting for submit to return, so all tasks are completed immediately.
  • ImmediateScheduledExecutor: A fake scheduled executor that uses a fake clock and 'ticking' of that to trigger scheduled tasks in the same thread as triggers the tick. Submitted tasks are always handled in the tick listener.

Console Utils

  • Console: An interface to interact with a console during testing.
  • ConsoleManager: Base class for managing a fake console during testing that will capture whats written to standard OUT and ERR and replace standard IN.

I/O and File Utils

  • ResourceUtil: Some simple utils for getting hand on resource content.
  • TestConfigMap: A class wrapping around a directory to make it behave as a kubernetes ConfigMap.

Text Utils

  • EnglishWords: A super-light text and word generator.

JUnit 4

Utilities specialized for JUnit 4.

  • ConsoleWatcher: A junit4 @Rule to set up and reset the console.
  • DataProviderUtil: Utility for generating matrices of arguments to from a data provider using com.tngtech.java:junit-dataprovider.

JUnit 5

Utilities specialized for JUnit 5.

  • ConsoleExtension: A junit5 extension to set up and reset the console, and give access to Console and TTY parameters.
  • ParamsProviderUtil: Utility for generating matrices of arguments to from a params provider.
  • DataSourceExtension: A junit 5 extension to set up a JDBC data source to be used in testing.

Major Version Changes

  • 4.x -> 5.x: FakeScheduledExecutor renamed ImmediateScheduledExecutor and new FakeScheduledExecutor created using a real background executor, but using the fake clock to trigger the scheduled tasks.