serenity-bdd / serenity-cucumber

Cucumber integration for the Serenity BDD Reporting library
Other
78 stars 74 forks source link

NullPointerException Running Cucumber with Serenity feature files directly from IntelliJ #130

Closed nomadcanuck closed 6 years ago

nomadcanuck commented 6 years ago

Attempting to run cucumber feature file with serenity directly from IntelliJ produces NullPointerException when using serenity-cucumber v1.6.13.

Workaround is to use serenity-cucumber v1.6.10 with serenity v1.8.21.

Steps to reproduce:

  1. serenity.version=1.9.0-rc.3 or 1.8.21
  2. serenity.cucumber.version=1.6.13
  3. setup and run as described in John Ferguson Smart blog at Running Cucumber with Serenity feature files directly from IntelliJ

Exception in thread "main" java.lang.NullPointerException at cucumber.runtime.formatter.SerenityReporter.initLineFilters(SerenityReporter.java:365) at cucumber.runtime.formatter.SerenityReporter.<init>(SerenityReporter.java:100) at net.serenitybdd.cucumber.CucumberWithSerenityRuntime.createSerenityEnabledRuntime(CucumberWithSerenityRuntime.java:37) at net.serenitybdd.cucumber.CucumberWithSerenityRuntime.using(CucumberWithSerenityRuntime.java:23) at net.serenitybdd.cucumber.cli.Main.run(Main.java:27) at net.serenitybdd.cucumber.cli.Main.main(Main.java:18)

wakaleo commented 6 years ago

What version of IntelliJ are you using?

nomadcanuck commented 6 years ago

Sorry about that, the IntelliJ version in use is:

IntelliJ IDEA 2017.3.5 EAP (Ultimate Edition) Build #IU-173.4674.1, built on February 26, 2018

also confirmed the same behaviour using updated version: IntelliJ IDEA 2018.1 EAP (Ultimate Edition) Build #UI-181.3986.9, built on February 27, 2018

java version "1.8.0_144"

asvdw commented 6 years ago

SerenityReporter constructor needs CucumberWithSerenity.currentRuntimeOptions() but CucumberWithSerenity.setRuntimeOptions(RuntimeOptions runtimeOptions) is called after ==> NPE :(

    <serenity.version>1.9.1</serenity.version>
    <serenity.cucumber.version>1.9.3</serenity.cucumber.version>
wakaleo commented 6 years ago

Thanks for finding this - the IntelliJ API may have changed. Please feel free to provide a PR as I won’t have time to look into this any time soon

asvdw commented 6 years ago

using cucumber.api.cli.Main as Main class seems to do the trick. Try to edit run configuration (in intelliJ, Run/Edit Configurations...) and use cucumber.api.cli.Main instead of net.serenitybdd.cucumber.cli.Main

wakaleo commented 6 years ago

@asvdw If you use cucumber.api.cli.Main you won't be running the feature file as a Serenity test.

asvdw commented 6 years ago

Yes I know, but it was ok for debugging purpose. Here is the simple fix ;)

henry6000 commented 6 years ago

Can some please create a version with this fix as it affected anyone using the cli

hweerasooriya commented 6 years ago

Can anyone fix the above-mentioned issue?

wakaleo commented 6 years ago

Should be fixed in serenity-cucumber 1.9.4

hweerasooriya commented 6 years ago

Thank you. Updating a new serenity cucumber version.