Skip to content

Conversation

@mehulimukherjee
Copy link
Contributor

  1. Added explicit null-precondition checks (Preconditions.notNull) across all core Launcher implementations (DefaultLauncher, DelegatingLauncher, InterceptingLauncher, and SessionPerRequestLauncher) so they fail fast with a clear PreconditionViolationException when passed null arguments.
  2. Ensured consistent validation for all discover and execute method variants.
  3. Introduced dedicated tests (LauncherPreconditionTests) to verify that each launcher correctly rejects null inputs and reports the expected error messages.

I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

mehulimukherjee and others added 13 commits January 14, 2026 14:13
… to v0.28.0 (junit-team#5269)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: mehulimukherjee <[email protected]>
…unit-team#5267)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: mehulimukherjee <[email protected]>
- Add a dedicated 'Kotlin Coroutines' section to the user guide
- Move existing suspend function documentation for context
- Recommend runTest over runBlocking for coroutine-based tests
- Update documentation demo to use runTest

Resolves junit-team#4768.

---------

Signed-off-by: cloud <[email protected]>
Co-authored-by: Marc Philipp <[email protected]>
Signed-off-by: mehulimukherjee <[email protected]>
Adopts the `SystemPropertyExtension`[1] from JUnit Pioneer into JUnit
Jupiter. While this is a faithful port some notable changes have been
made. With that in mind the API status has been set to experimental.

### `@RestoreSystemProperties` uses `Properties::clone`

When using `@RestoreSystemProperties` JUnit Pioneer would create a copy
of the effective properties in the object. This would include any
defaults as if they were regular values. I.e:

```java
static Properties createEffectiveClone(Properties original) {
	Properties clone = new Properties();

	// This implementation is used because:
	// System.getProperties() returns the actual Properties object, not a copy.
	// Clone doesn't include nested defaults, but propertyNames() does.
	original.propertyNames().asIterator().forEachRemaining(k -> {
		String v = original.getProperty(k.toString());

		if (v != null) {
			// v will be null if the actual value was an object
			clone.put(k, original.getProperty(k.toString()));
		}
	});

	return clone;
}
```

 JUnit instead uses `Properties::clone` and performs a best effort
 attempt to detect default properties and fail if any were detected. For
 classes that extend `Properties` it is assumed that `clone` is
 implemented with sufficient fidelity. I.e:

```java
static Properties cloneWithoutDefaults(ExtensionContext context, Properties properties) {
	// Custom implementations have to implement clone correctly.
	if (properties.getClass() == Properties.class) {
		throwIfHasObservableDefaults(context, properties);
	}
	return (Properties) properties.clone();
}
```

We do this because:

1. System properties are to the best of our knowledge created without
defaults. Nor are we aware of a good usecase for defaults. If you do
have a use case for this, please do create  a new issue to explain it.
2. Using `Properties::clone` provides a contract that is easier to
document and understand. It also allows subclasses of `Properties` to be
provided to tests. For example, a variant that does include defaults
when cloned.

### Restore "compromised"  entries

While strongly discouraged non-string values can be added to a
properties object.  The Pioneer implementation would not restore these
"compromised" values. This has been fixed in the JUnit implementation.

Closes: junit-team#4726

1. https://github.com/junit-pioneer/junit-pioneer/blob/062ce51296dab909119fd6c9f090b9d6a2982530/src/main/java/org/junitpioneer/jupiter/SystemPropertyExtension.java

Signed-off-by: mehulimukherjee <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: mehulimukherjee <[email protected]>
@mehulimukherjee mehulimukherjee force-pushed the bugfix/launcher-preconditions-check branch from ef18e65 to dffed09 Compare January 14, 2026 01:14
@testlens-app
Copy link

testlens-app bot commented Jan 14, 2026

✅ All tests passed ✅

🏷️ Commit: 4d00857
▶️ Tests: 32662 executed
⚪️ Checks: 15/15 completed


Learn more about TestLens at testlens.app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants