serenity-bdd / serenity-cucumber4

Other
13 stars 10 forks source link

Getting java.lang.NullPointerException: No BaseStepListener has been registered #29

Open Madhan-alt opened 4 years ago

Madhan-alt commented 4 years ago

I am getting below error

java.lang.NullPointerException: No BaseStepListener has been registered at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:900) at net.thucydides.core.steps.StepEventBus.getBaseStepListener(StepEventBus.java:138) at net.serenitybdd.screenplay.EventBusInterface.aStepHasFailedInTheCurrentExample(EventBusInterface.java:61) at net.serenitybdd.screenplay.Actor.anOutOfStepErrorOccurred(Actor.java:306) at net.serenitybdd.screenplay.Actor.perform(Actor.java:216) at net.serenitybdd.screenplay.Actor.attemptsTo(Actor.java:171) at com.serenitycucumbertests.steps.SearchForUserSteps.has_opened_authorization_UI(SearchForUserSteps.java:33) at ?.'authadmin' has opened authorization UI.(src/main/resources/features/portalui/search_for_a_user.feature:5)

I am trying to invoke serenityWithCucumber programmatically from java main method.

This is the logic in my main method

String[] defaultOptions = { "--glue", "com.serenitycucumbertests", "--plugin", "pretty", "--plugin", "junit:target/cucumber-reports/Cucumber.xml", "--plugin", "html:target/cucumber-reports/html/", "--plugin", "pretty:target/cucumber-pretty.txt", "src/main/resources/features/" }; try { System.setProperty("webdriver.driver","chrome"); System.setProperty("webdriver.chrome.driver","src/main/resources/chromedriver.exe"); System.setProperty("use.driver.service.pool","false");

        net.serenitybdd.cucumber.cli.Main.main(defaultOptions);
    } catch (Throwable e) {
        e.printStackTrace();
    }

This is my gradle file

plugins { id 'org.springframework.boot' version '2.1.3.RELEASE' id 'io.spring.dependency-management' version '1.0.9.RELEASE' id 'java' }

repositories { mavenLocal() jcenter() }

group = 'com.cerner.integration.test' version = '1.0' sourceCompatibility = '1.8'

/**

dependencies { implementation 'org.springframework.boot:spring-boot-starter' implementation 'org.springframework:spring-web:5.1.5.RELEASE'

implementation 'io.cucumber:cucumber-core:4.2.0'
implementation 'io.cucumber:cucumber-junit:4.2.0'
implementation 'io.cucumber:cucumber-java:4.2.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'net.serenity-bdd:serenity-cucumber4:1.0.21'
implementation 'net.serenity-bdd:serenity-core:2.0.81'
implementation  group: 'net.serenity-bdd', name: 'serenity-ensure', version: '2.0.81'
implementation  group: 'net.serenity-bdd', name: 'serenity-assertions', version: '2.0.81'
implementation  group: 'net.serenity-bdd', name: 'serenity-screenplay-rest', version: '2.0.81'
implementation  group: 'net.serenity-bdd', name: 'serenity-screenplay-webdriver', version: '2.0.81'
implementation  group: 'net.serenity-bdd', name: 'serenity-screenplay', version: '2.0.81'

testCompile 'org.springframework.boot:spring-boot-starter-test:2.1.3.RELEASE'

}

Could anyone help, how to execute tests from an executable jar and resolve this error.

cliviu commented 4 years ago

Hi @Madhan-alt , please provide a small project for us which reproduces your problem. Thanks !