Failure Threshold Support for @RepeatedTest in Junit
This commit is contained in:
parent
b0be6dbf36
commit
62195e14d4
|
@ -1,21 +1,16 @@
|
||||||
package com.baeldung.junit5.failurethreshold;
|
package com.baeldung.junit5.failurethreshold;
|
||||||
|
|
||||||
import org.junit.jupiter.api.RepeatedTest;
|
import org.junit.jupiter.api.RepeatedTest;
|
||||||
|
import java.util.Random;
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
class FailureThresholdUnitTest {
|
class FailureThresholdUnitTest {
|
||||||
|
Random random = new Random();
|
||||||
|
|
||||||
@RepeatedTest(value = 5, failureThreshold = 1)
|
@RepeatedTest(value = 10, failureThreshold = 2)
|
||||||
void givenTextFile_whenItIsReadAndContainsSpecifiedWordRepeatedly_thenMatchingLinesFound() throws IOException {
|
void givenRandomNumberGenerator_whenGeneratingRandomNumber_thenNumberShouldBeWithinRange() {
|
||||||
String filePath = "test_file.txt";
|
int number = random.nextInt(10);
|
||||||
try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
|
assertTrue(number <= 9);
|
||||||
String line = reader.readLine();
|
|
||||||
assertTrue(line.contains("The"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
The Efficacy of meta-cognitive therapy on the symptoms of obsessive-compulsive disorder in patients with multiple sclerosis
|
|
Loading…
Reference in New Issue