You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if an exception is thrown from an annotated setter method, an ugly stacktrace results. ArgSpec.set rethrows PicocliException rather than rethrowing it, but when the setter is reflection based, the exception caught is an InvocationTargetException, not the actual exception thrown in the method.
Provide better handling for InvocationTargetException.
org.junit.platform.commons.JUnitException: Error parsing command-line arguments
at org.junit.platform.console.options.PicocliCommandLineOptionsParser.parse(PicocliCommandLineOptionsParser.java:41)
at org.junit.platform.console.options.PicocliCommandLineOptionsParserTests.parseArgLine(PicocliCommandLineOptionsParserTests.java:555)
at org.junit.platform.console.options.PicocliCommandLineOptionsParserTests.lambda$parseValidConfigurationParameters$143(PicocliCommandLineOptionsParserTests.java:488)
at org.junit.jupiter.api.AssertAll.lambda$assertAll$1(AssertAll.java:68)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
at java.base/java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:442)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:66)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:43)
at org.junit.jupiter.api.AssertAll.assertAll(AssertAll.java:37)
at org.junit.jupiter.api.Assertions.assertAll(Assertions.java:1067)
at org.junit.platform.console.options.PicocliCommandLineOptionsParserTests.parseValidConfigurationParameters(PicocliCommandLineOptionsParserTests.java:479)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:515)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:171)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:167)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:114)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:59)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:131)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:127)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:107)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1378)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:136)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:127)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:107)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1378)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:136)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:127)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:107)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:52)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:184)
at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:152)
at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:166)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:145)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:92)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: picocli.CommandLine$ParameterException: PicocliException: Could not invoke public void org.junit.platform.console.options.AvailableOptions.setConfigurationParameters(java.util.Map) with {foo=bar, baz=qux} while processing argument at or before arg[3] 'baz=qux' in [--config, foo=bar, --config, baz=qux]: picocli.CommandLine$PicocliException: Could not invoke public void org.junit.platform.console.options.AvailableOptions.setConfigurationParameters(java.util.Map) with {foo=bar, baz=qux}
at picocli.CommandLine$ParameterException.create(CommandLine.java:8754)
at picocli.CommandLine$ParameterException.access$9700(CommandLine.java:8678)
at picocli.CommandLine$Interpreter.parse(CommandLine.java:5527)
at picocli.CommandLine$Interpreter.parse(CommandLine.java:5421)
at picocli.CommandLine.parseArgs(CommandLine.java:601)
at org.junit.platform.console.options.PicocliCommandLineOptionsParser.parse(PicocliCommandLineOptionsParser.java:37)
... 56 more
Caused by: picocli.CommandLine$PicocliException: Could not invoke public void org.junit.platform.console.options.AvailableOptions.setConfigurationParameters(java.util.Map) with {foo=bar, baz=qux}
at picocli.CommandLine$Model$MethodBinding.set(CommandLine.java:5090)
at picocli.CommandLine$Model$ArgSpec.setValue(CommandLine.java:4031)
at picocli.CommandLine$Interpreter.applyValuesToMapField(CommandLine.java:5921)
at picocli.CommandLine$Interpreter.applyOption(CommandLine.java:5823)
at picocli.CommandLine$Interpreter.processStandaloneOption(CommandLine.java:5726)
at picocli.CommandLine$Interpreter.processArguments(CommandLine.java:5639)
at picocli.CommandLine$Interpreter.parse(CommandLine.java:5521)
... 59 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at picocli.CommandLine$Model$MethodBinding.set(CommandLine.java:5086)
... 65 more
Caused by: picocli.CommandLine$PicocliException: Duplicate key 'foo' for values 'bar' and 'bar'.
at org.junit.platform.console.options.AvailableOptions.setConfigurationParameters(AvailableOptions.java:254)
... 70 more
The text was updated successfully, but these errors were encountered:
After fixing this, the stack trace now looks like the below. This looks better.
org.junit.platform.console.ConsoleLauncher --config foo=bar --config foo=baz
Exception in thread "main" org.junit.platform.commons.JUnitException: Error parsing command-line arguments
at org.junit.platform.console.options.PicocliCommandLineOptionsParser.parse(PicocliCommandLineOptionsParser.java:38)
at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:68)
at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:47)
at org.junit.platform.console.ConsoleLauncher.main(ConsoleLauncher.java:39)
Caused by: picocli.CommandLine$ParameterException: Duplicate key 'foo' for values 'bar' and 'baz'.
at org.junit.platform.console.options.AvailableOptions.setConfigurationParameters(AvailableOptions.java:263)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at picocli.CommandLine$Model$MethodBinding.set(CommandLine.java:5097)
at picocli.CommandLine$Model$ArgSpec.setValue(CommandLine.java:4041)
at picocli.CommandLine$Interpreter.applyValuesToMapField(CommandLine.java:5935)
at picocli.CommandLine$Interpreter.applyOption(CommandLine.java:5837)
at picocli.CommandLine$Interpreter.processStandaloneOption(CommandLine.java:5740)
at picocli.CommandLine$Interpreter.processArguments(CommandLine.java:5653)
at picocli.CommandLine$Interpreter.parse(CommandLine.java:5535)
at picocli.CommandLine$Interpreter.parse(CommandLine.java:5435)
at picocli.CommandLine.parseArgs(CommandLine.java:601)
at org.junit.platform.console.options.PicocliCommandLineOptionsParser.parse(PicocliCommandLineOptionsParser.java:34)
... 3 more
Currently, if an exception is thrown from an annotated setter method, an ugly stacktrace results.
ArgSpec.set
rethrowsPicocliException
rather than rethrowing it, but when the setter is reflection based, the exception caught is anInvocationTargetException
, not the actual exception thrown in the method.Provide better handling for
InvocationTargetException
.(Needed for junit-team/junit5#1498 )
The text was updated successfully, but these errors were encountered: