Skip to content

Commit 76c70a0

Browse files
committed
Use assertThrows()
1 parent db8c828 commit 76c70a0

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

src/test/java/org/apache/commons/cli/HelpFormatterTest.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
1919

2020
import static org.junit.jupiter.api.Assertions.assertEquals;
2121
import static org.junit.jupiter.api.Assertions.assertNull;
22+
import static org.junit.jupiter.api.Assertions.assertThrows;
2223
import static org.junit.jupiter.api.Assertions.fail;
2324

2425
import java.io.ByteArrayOutputStream;
@@ -349,19 +350,8 @@ public void testPrintHelpNewlineHeader() {
349350
@Test
350351
public void testPrintHelpWithEmptySyntax() {
351352
final HelpFormatter formatter = new HelpFormatter();
352-
try {
353-
formatter.printHelp(null, new Options());
354-
fail("null command line syntax should be rejected");
355-
} catch (final IllegalArgumentException e) {
356-
// expected
357-
}
358-
359-
try {
360-
formatter.printHelp("", new Options());
361-
fail("empty command line syntax should be rejected");
362-
} catch (final IllegalArgumentException e) {
363-
// expected
364-
}
353+
assertThrows(IllegalArgumentException.class, () -> formatter.printHelp(null, new Options()), "null command line syntax should be rejected");
354+
assertThrows(IllegalArgumentException.class, () -> formatter.printHelp("", new Options()), "null command line syntax should be rejected");
365355
}
366356

367357
@Test

0 commit comments

Comments
 (0)