junit-team/junit5 · warning · DateTimeParseException
Timeout duration is not in the expected format (<number> [ns
Error message
Timeout duration is not in the expected format (<number> [ns|μs|ms|s|m|h|d])
What it means
Thrown by TimeoutDurationParser.parse() when the supplied text does not match the expected pattern '([1-9]\d*) ?((?:[nμm]?s)|m|h|d)?' (case-insensitive, unicode-aware). The format is a positive integer optionally followed by a unit abbreviation (ns, μs, ms, s, m, h, d); seconds is the default when no unit is given. Note: when used via TimeoutConfiguration for config parameters, this exception is caught and logged as a warning with the timeout ignored, so it does not surface as a test failure in that path.
Source
Thrown at junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TimeoutDurationParser.java:58
"ns", NANOSECONDS, //
"μs", MICROSECONDS, //
"ms", MILLISECONDS, //
"s", SECONDS, //
"m", MINUTES, //
"h", HOURS, //
"d", DAYS //
);
TimeoutDuration parse(CharSequence text) throws DateTimeParseException {
Matcher matcher = PATTERN.matcher(text);
if (matcher.matches()) {
long value = Long.parseLong(matcher.group(1));
String unitAbbreviation = matcher.group(2);
TimeUnit unit = unitAbbreviation == null ? SECONDS
: requireNonNull(UNITS_BY_ABBREVIATION.get(unitAbbreviation.toLowerCase(Locale.ENGLISH)));
return new TimeoutDuration(value, unit);
}
throw new DateTimeParseException("Timeout duration is not in the expected format (<number> [ns|μs|ms|s|m|h|d])",
text, 0);
}
}
View on GitHub (pinned to 956246301e)
Solutions
- Use one of the supported unit abbreviations: ns, μs, ms, s, m, h, d — e.g., '500ms' not '500millis'
- Ensure the value is a positive integer (regex requires [1-9]\d*), so '0' and decimals are invalid
- Check the log output for the 'Ignored invalid timeout' warning to confirm the parser rejected your value
- Omit the unit entirely to default to seconds (e.g., '30' means 30 seconds)
Example fix
# before (in junit-platform.properties) junit.jupiter.execution.timeout.default = 500millis # after junit.jupiter.execution.timeout.default = 500ms
Defensive patterns
Strategy: validation
Validate before calling
// Validate a timeout config string before relying on it
String timeout = "500ms";
Pattern p = Pattern.compile("([1-9]\\d*) ?((?:[nμm]?s)|m|h|d)?",
Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
if (!p.matcher(timeout).matches()) {
throw new IllegalArgumentException(
"Invalid timeout format: " + timeout + ". Expected: <number> [ns|μs|ms|s|m|h|d]");
}
Set<String> validUnits = Set.of("ns", "μs", "ms", "s", "m", "h", "d"); Prevention
- Double-check timeout values in junit-platform.properties against the allowed units: ns, μs, ms, s, m, h, d
- Remember the value must be a positive integer (no leading zero, no decimals)
- Watch for log warnings containing 'Ignored invalid timeout' — they indicate the parser rejected your value silently
When it happens
Trigger: Calling TimeoutDurationParser.parse(CharSequence) with a string that fails the regex: zero ('0s'), negative ('-5s'), decimal ('1.5s'), unsupported unit ('5min'), trailing characters ('5 seconds'), or a value starting with 0. This is invoked when parsing junit.jupiter.execution.timeout.* configuration parameter values.
Common situations: Setting junit.jupiter.execution.timeout.testable.method or junit.jupiter.execution.timeout.default in junit-platform.properties with a typo, wrong unit abbreviation (e.g., 'min' instead of 'm', 'sec' instead of 's'), or a zero/decimal value. The value is silently ignored and a warning is logged, so timeouts silently don't apply.
Related errors
- Could not map TimeUnit <unit> to ChronoUnit
- thread mode must not be INFERRED
- Scheduled executor could not be stopped in an orderly manner
- Failed to create output directory
- The following TestInstanceFactory extensions were registered
AI-assisted analysis of junit-team/junit5@956246301e (2026-08-04).
Data as JSON: /data/errors/42324cf4e227631a.json.
Report an issue: GitHub.