I wrote a test to check if RNG is hanging
public class StringUtilsTest {
@Test
@Timeout(value = 10)
public void repeated_generateRandomStringOfDigits() {
for (int i=0; i<5; ++i) {
StringUtils.generateRandomStringOfDigits(10);
try {
Thread.sleep(1);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
}
}
}
}
but it doesn't work as expected: if RNG hangs the test hangs too, ignoring the timeout.
How to accomplish?
Use this instead of the @Timeout :