diff --git a/core-java-modules/core-java-io-4/src/test/java/com/baeldung/scanner/ScannerUnitTest.java b/core-java-modules/core-java-io-4/src/test/java/com/baeldung/scanner/ScannerUnitTest.java index f11f3d032d..cb6ce5fb2d 100644 --- a/core-java-modules/core-java-io-4/src/test/java/com/baeldung/scanner/ScannerUnitTest.java +++ b/core-java-modules/core-java-io-4/src/test/java/com/baeldung/scanner/ScannerUnitTest.java @@ -8,26 +8,27 @@ import java.util.regex.*; import static org.junit.jupiter.api.Assertions.assertEquals; public class ScannerUnitTest { - @Test public void scannerSkipUsingPattern() { + @Test public void givenScannerWithPattern_thenSkipUsingPattern() { String str = "Java scanner skip tutorial"; // Instantiates Scanner Scanner sc = new Scanner(str); // By using skip(Pattern) method is to skip that meets the given pattern sc.skip(Pattern.compile(".ava")); - assertEquals(sc.nextLine(), " scanner skip tutorial"); + + assertEquals(" scanner skip tutorial", sc.nextLine()); // Scanner closed sc.close(); } - @Test public void scannerSkipUsingStringPattern() { + @Test public void givenScannerWithString_thenSkipUsingStringPattern() { String str = "Java scanner skip tutorial"; // Instantiates Scanner Scanner sc = new Scanner(str); // By using skip(String) method is to skip that meets the given // pattern constructed from the given String sc.skip("Java"); - assertEquals(sc.nextLine(), " scanner skip tutorial"); + assertEquals(" scanner skip tutorial", sc.nextLine()); // Scanner closed sc.close(); }