Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConsoleLauncher: VerboseTreePrintingListener - format specifier in exception message throws java.util.MissingFormatArgumentException #1600

Closed
andrzejo opened this issue Sep 25, 2018 · 4 comments

Comments

@andrzejo
Copy link

andrzejo commented Sep 25, 2018

Overview

Bug in VerboseTreePrintingListener:

When using ConsoleLauncher with --details options set to verbose and in test method is thrown an exception with message containing format specifier (e.g. %c - "My exception message with %c specifier") then VerboseTreePrintingListener throws MissingFormatArgumentException exception.

example test:

package com.thulium.selenium;

import org.junit.jupiter.api.Test;

class VerboseTreePrintingListenerTest {

    @Test
    void shouldLogException() {
        throw new RuntimeException("Message with %c formatter.");
    }
}

command (run from InteliJ):

ConsoleLauncher --reports-dir /tmp/selenium --select-class com.thulium.selenium.VerboseTreePrintingListenerTest --details verbose

Stack trace:

java.util.MissingFormatArgumentException: Format specifier '%c'
	at java.util.Formatter.format(Formatter.java:2519)
	at java.io.PrintWriter.format(PrintWriter.java:905)
	at java.io.PrintWriter.printf(PrintWriter.java:804)
	at org.junit.platform.console.tasks.VerboseTreePrintingListener.printf(VerboseTreePrintingListener.java:159)
	at org.junit.platform.console.tasks.VerboseTreePrintingListener.printDetail(VerboseTreePrintingListener.java:183)
	at org.junit.platform.console.tasks.VerboseTreePrintingListener.lambda$executionFinished$0(VerboseTreePrintingListener.java:104)
	at java.util.Optional.ifPresent(Optional.java:159)
	at org.junit.platform.console.tasks.VerboseTreePrintingListener.executionFinished(VerboseTreePrintingListener.java:104)
	at org.junit.platform.launcher.core.TestExecutionListenerRegistry$CompositeTestExecutionListener.lambda$executionFinished$3(TestExecutionListenerRegistry.java:77)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at org.junit.platform.launcher.core.TestExecutionListenerRegistry.notifyTestExecutionListeners(TestExecutionListenerRegistry.java:51)
	at org.junit.platform.launcher.core.TestExecutionListenerRegistry.access$100(TestExecutionListenerRegistry.java:27)
	at org.junit.platform.launcher.core.TestExecutionListenerRegistry$CompositeTestExecutionListener.executionFinished(TestExecutionListenerRegistry.java:77)
	at org.junit.platform.launcher.core.ExecutionListenerAdapter.executionFinished(ExecutionListenerAdapter.java:56)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.reportCompletion(NodeTestTask.java:154)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:76)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	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:110)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:71)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	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:110)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:71)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
	at org.junit.platform.console.tasks.ConsoleTestExecutor.executeTests(ConsoleTestExecutor.java:65)
	at org.junit.platform.console.tasks.ConsoleTestExecutor.lambda$execute$0(ConsoleTestExecutor.java:57)
	at org.junit.platform.console.tasks.CustomContextClassLoaderExecutor.invoke(CustomContextClassLoaderExecutor.java:33)
	at org.junit.platform.console.tasks.ConsoleTestExecutor.execute(ConsoleTestExecutor.java:57)
	at org.junit.platform.console.ConsoleLauncher.executeTests(ConsoleLauncher.java:84)
	at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:74)
	at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:47)
	at org.junit.platform.console.ConsoleLauncher.main(ConsoleLauncher.java:39)
@marcphilipp
Copy link
Member

@sormuras Could you take a look at this one, please?

@sormuras sormuras self-assigned this Sep 25, 2018
@sormuras
Copy link
Member

Definitely a bug. Should also happen, when a @DisplayName("Some %c ool test name...") is provided. Will add tests and a fix later today.

@andrzejo
Copy link
Author

@sormuras Great :)

sormuras added a commit that referenced this issue Sep 27, 2018
@sormuras
Copy link
Member

Thanks for the report, @andrzejo ... fixed it on master via 6eb5531

@marcphilipp marcphilipp modified the milestones: 5.4 M1, 5.3.2 Nov 16, 2018
@sormuras sormuras mentioned this issue Nov 20, 2018
22 tasks
sbrannen pushed a commit that referenced this issue Nov 20, 2018
Prior to this commit format specifiers in exception messages resulted
in a MissingFormatArgumentException. Now every user-defined string is
treated as an argument itself, effectively preventing a reformatting
of the passed string.

Closes #1600
sormuras added a commit that referenced this issue Nov 20, 2018
sormuras added a commit that referenced this issue Nov 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants