You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/04/08 13:13:21 UTC
(commons-cli) 11/12: Use assertThrows()
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git
commit 76c70a057583e3d9d5208c479b6cd04120c68105
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 8 09:11:54 2024 -0400
Use assertThrows()
---
.../java/org/apache/commons/cli/HelpFormatterTest.java | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/src/test/java/org/apache/commons/cli/HelpFormatterTest.java b/src/test/java/org/apache/commons/cli/HelpFormatterTest.java
index 97242a4..d23f943 100644
--- a/src/test/java/org/apache/commons/cli/HelpFormatterTest.java
+++ b/src/test/java/org/apache/commons/cli/HelpFormatterTest.java
@@ -19,6 +19,7 @@ package org.apache.commons.cli;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayOutputStream;
@@ -349,19 +350,8 @@ public class HelpFormatterTest {
@Test
public void testPrintHelpWithEmptySyntax() {
final HelpFormatter formatter = new HelpFormatter();
- try {
- formatter.printHelp(null, new Options());
- fail("null command line syntax should be rejected");
- } catch (final IllegalArgumentException e) {
- // expected
- }
-
- try {
- formatter.printHelp("", new Options());
- fail("empty command line syntax should be rejected");
- } catch (final IllegalArgumentException e) {
- // expected
- }
+ assertThrows(IllegalArgumentException.class, () -> formatter.printHelp(null, new Options()), "null command line syntax should be rejected");
+ assertThrows(IllegalArgumentException.class, () -> formatter.printHelp("", new Options()), "null command line syntax should be rejected");
}
@Test