diff --git a/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/failurethreshold/FailureThresholdUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/failurethreshold/FailureThresholdUnitTest.java new file mode 100644 index 0000000000..8f0043cf51 --- /dev/null +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/failurethreshold/FailureThresholdUnitTest.java @@ -0,0 +1,21 @@ +package com.baeldung.junit5.failurethreshold; + +import org.junit.jupiter.api.RepeatedTest; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +class FailureThresholdUnitTest { + + @RepeatedTest(value = 5, failureThreshold = 1) + void givenTextFile_whenItIsReadAndContainsSpecifiedWordRepeatedly_thenMatchingLinesFound() throws IOException { + String filePath = "test_file.txt"; + try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) { + String line = reader.readLine(); + assertTrue(line.contains("The")); + } + } +} diff --git a/testing-modules/junit5-annotations/test_file.txt b/testing-modules/junit5-annotations/test_file.txt new file mode 100644 index 0000000000..f29ab3685b --- /dev/null +++ b/testing-modules/junit5-annotations/test_file.txt @@ -0,0 +1 @@ +The Efficacy of meta-cognitive therapy on the symptoms of obsessive-compulsive disorder in patients with multiple sclerosis \ No newline at end of file