Skip to content

Commit 9604be8

Browse files
committed
[Change] ArgumentsRunner 调整'InvocationTargetException'处理方式;
[Add] ArgumentsRunnerInstanceMethodTest, ArgumentsRunnerStaticMethodTest 增加针对方法'getCommandNames'的测试项;
1 parent ff7fd12 commit 9604be8

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/main/java/net/lamgc/utils/base/runner/ArgumentsRunner.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,10 @@ public Object run(Object object, String[] args) throws RunnerException {
189189
paramList.toArray(params);
190190
try {
191191
return targetMethod.invoke(object, params);
192-
} catch (IllegalAccessException | InvocationTargetException e) {
192+
} catch (IllegalAccessException e) {
193193
throw new DeveloperRunnerException(e);
194+
} catch (InvocationTargetException e) {
195+
throw new DeveloperRunnerException(e.getTargetException());
194196
}
195197

196198
}

src/test/java/net/lamgc/utils/base/runner/ArgumentsRunnerInstanceMethodTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
public class ArgumentsRunnerInstanceMethodTest {
1313

1414
private static InstanceRunnerTestMain testMain = new InstanceRunnerTestMain();
15-
15+
16+
@Test
17+
public void getCommandNamesTest() {
18+
new ArgumentsRunner(InstanceRunnerTestMain.class).getCommandNames();
19+
}
20+
1621
@Test
1722
public void normalOperationTest() {
1823
ArgumentsRunner.run(InstanceRunnerTestMain.class, testMain,

src/test/java/net/lamgc/utils/base/runner/ArgumentsRunnerStaticMethodTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
public class ArgumentsRunnerStaticMethodTest {
1313

14+
@Test
15+
public void getCommandNamesTest() {
16+
new ArgumentsRunner(InstanceRunnerTestMain.class).getCommandNames();
17+
}
18+
1419
@Test
1520
public void normalOperationTest() {
1621
ArgumentsRunner.run(StaticRunnerTestMain.class,

0 commit comments

Comments
 (0)