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

Project did not run #33

Closed
Jeredriq opened this issue Oct 17, 2018 · 10 comments · Fixed by cucumber/cucumber-jvm#1484
Closed

Project did not run #33

Jeredriq opened this issue Oct 17, 2018 · 10 comments · Fixed by cucumber/cucumber-jvm#1484

Comments

@Jeredriq
Copy link

I didn't changed anything but for some reason whenever try to run this I get the stacktrace below

`
java.lang.NullPointerException: No format for key undefıned

at cucumber.runtime.formatter.AnsiFormats.get(AnsiFormats.java:51)
at cucumber.runtime.formatter.PrettyFormatter.printStep(PrettyFormatter.java:207)
at cucumber.runtime.formatter.PrettyFormatter.handleTestStepFinished(PrettyFormatter.java:145)
at cucumber.runtime.formatter.PrettyFormatter.access$300(PrettyFormatter.java:32)
at cucumber.runtime.formatter.PrettyFormatter$6.receive(PrettyFormatter.java:78)
at cucumber.runtime.formatter.PrettyFormatter$6.receive(PrettyFormatter.java:75)
at cucumber.runner.AbstractEventPublisher.send(AbstractEventPublisher.java:45)
at cucumber.runner.AbstractEventBus.send(AbstractEventBus.java:9)
at cucumber.runner.TimeServiceEventBus.send(TimeServiceEventBus.java:3)
at cucumber.runner.ThreadLocalRunnerSupplier$SynchronizedEventBus.send(ThreadLocalRunnerSupplier.java:90)
at cucumber.runner.ThreadLocalRunnerSupplier$LocalEventBus.send(ThreadLocalRunnerSupplier.java:63)
at cucumber.runner.TestStep.run(TestStep.java:57)
at cucumber.runner.PickleStepTestStep.run(PickleStepTestStep.java:43)
at cucumber.runner.TestCase.run(TestCase.java:44)
at cucumber.runner.Runner.runPickle(Runner.java:40)
at cucumber.runtime.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:146)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:68)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:23)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:73)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:124)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:65)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at cucumber.api.junit.Cucumber$1.evaluate(Cucumber.java:133)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
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)

`

@aslakhellesoy
Copy link
Contributor

What version are you using?

Can you prepare a Minimal, Complete, and Verifiable example in a git repo please?

@Jeredriq
Copy link
Author

Well, bad for me I cant reach git repo from my work place.

But I assure you all I did was just download this https://github.com/cucumber/cucumber-java-skeleton/ in zip file and open it and tried running tests

@aslakhellesoy
Copy link
Contributor

Please disregard my last comment. Can you tell us what OS you’re on and what Java version you’re using?

@Jeredriq
Copy link
Author

Windows 7 Enterprise Service Pack 1 and Java 1.8.0_121

@onurozcelik
Copy link

Change your OS language to English and try again.

@Jeredriq
Copy link
Author

It works perfectly, thanks @onurozcelik

@aslakhellesoy
Copy link
Contributor

I'm reopening this - there should be a better error message.

@aslakhellesoy aslakhellesoy reopened this Oct 18, 2018
@mpkorstanje
Copy link
Contributor

I can't make sense of the error.

java.lang.NullPointerException: No format for key undefıned
at cucumber.runtime.formatter.AnsiFormats.get(AnsiFormats.java:51)

It's right there!

private static final Map<String, Format> formats = new HashMap<String, Format>() {{
        put("undefined", new ColorFormat(AnsiEscapes.YELLOW));
        ....
}};

Much less of how the OS language influences this.

@mpkorstanje
Copy link
Contributor

Ah found it. It's in PrettyFormatter

        String formattedStepText = formatStepText(keyword, stepText, formats.get(result.getStatus().lowerCaseN11ame()), formats.get(result.getStatus().lowerCaseName() + "_arg"), testStep.getDefinitionArgument());

Which calls Result:

        public String lowerCaseName() {
            return name().toLowerCase();
        }

Which calls String

public String toLowerCase() {
        return toLowerCase(Locale.getDefault());
    }

Which uses a Locale which notes:

     * Converts all of the characters in this {@code String} to lower
     * case using the rules of the default locale. This is equivalent to calling
     * {@code toLowerCase(Locale.getDefault())}.
     * <p>
     * <b>Note:</b> This method is locale sensitive, and may produce unexpected
     * results if used for strings that are intended to be interpreted locale
     * independently.
     * Examples are programming language identifiers, protocol keys, and HTML
     * tags.
     * For instance, {@code "TITLE".toLowerCase()} in a Turkish locale
     * returns {@code "t\u005Cu0131tle"}, where '\u005Cu0131' is the
     * LATIN SMALL LETTER DOTLESS I character.
     * To obtain correct results for locale insensitive strings, use
     * {@code toLowerCase(Locale.ROOT)}.
     * <p>

mpkorstanje added a commit to cucumber/cucumber-jvm that referenced this issue Oct 18, 2018
Several formatters use lowercased string representations of enum
values. Doing this withouth an explicit locale results in the
default locale being used. This may lead to surpricing errors.

Fixes: cucumber/cucumber-java-skeleton#33
mpkorstanje added a commit to cucumber/cucumber-jvm that referenced this issue Oct 18, 2018
Several plugins use lowercased string representations of enum
values. Doing this without an explicit locale results in the
default locale being used. This may lead to surprising errors.

Fixes: cucumber/cucumber-java-skeleton#33
@aslakhellesoy
Copy link
Contributor

Nice one @mpkorstanje!

@aslakhellesoy aslakhellesoy reopened this Oct 18, 2018
mpkorstanje added a commit to cucumber/cucumber-jvm that referenced this issue Oct 18, 2018
Several plugins use lowercased string representations of enum
values. Doing this without an explicit locale results in the
default locale being used. This may lead to surprising errors.

Fixes: cucumber/cucumber-java-skeleton#33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants