System Stubs

System Stubs is used to test code which depends on methods in java.lang.System.

class WithEnvironmentVariables {
	private EnvironmentVariables variables = new EnvironmentVariables("input", "foo");

	void hasAccessToEnvironmentVariables() {

	void changeEnvironmentVariablesDuringTest() {
		variables.set("input", "bar");

Go to the linked site

Tags: #java #junit5 #test
Oct 2023, 03.


My next events:
🗓 Apr 04 16:30 JDevSummitIL Getting Started with the Micronaut Framework