-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Milestone
Description
Sometimes it is necessary to test a consecutive range of enum constants in a unit test. The existing matchers of @EnumSource can't help here.
As Enum constants have a natural order, it would be useful to support a range in @EnumSource. If a bound is not specified, it is considered unbounded.
Following example would work then: all constants of ChronoUnit starting at WEEKS aren't supported by Instant.plus(..).
class InstantTests {
@EnumSource(from = "WEEKS")
@ParameterizedTest
void plus_unsupportedUnits(ChronoUnit unit) {
Instant now = Instant.now();
assertThrows(UnsupportedTemporalTypeException.class, () -> now.plus(1, unit));
}
...
Candidates are
@EnumSource(from = "..", to = ".."),@EnumSource(begin = "..", end = "..")or@EnumSource(start = "..", end = "..")- ...
The existing matchers could be applied to a specified range additionally.
Deliverables
-
@EnumSourcewith optionalfromandtoattributes - Update documentation and release notes