You can create a typed Rangeclass with a method within:
public class Range<T extends Comparable<T>> {
private final T min;
private final T max;
public Range( T min, T max ) {
this.min = min;
this.max = max;
}
public boolean within( T value ) {
return min.compareTo(value) <= 0 && max.compareTo(value) >= 0;
}
}
If min and max were the same for the test group, you can reuse your object Rangefor all tests.
FWIW, this seems convenient!
source
share