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

java.lang.NullPointerException: No BaseStepListener has been registered #1295

Closed
kutzi opened this issue Jul 4, 2018 · 30 comments
Closed

java.lang.NullPointerException: No BaseStepListener has been registered #1295

kutzi opened this issue Jul 4, 2018 · 30 comments

Comments

@kutzi
Copy link
Contributor

kutzi commented Jul 4, 2018

Upgraded to serenity-core/serenity-cucumber 1.9.27/1.9.8 and got this already twice:
(previous versions 1.9.17/1.9.7)

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:133)
	at net.thucydides.core.steps.StepEventBus.updateCurrentStepTitle(StepEventBus.java:578)
	at cucumber.runtime.formatter.SerenityReporter.handleTestStepStarted(SerenityReporter.java:306)
	at cucumber.runtime.formatter.SerenityReporter.lambda$new$3(SerenityReporter.java:119)
	at cucumber.runner.EventBus.send(EventBus.java:28)
	at cucumber.api.TestStep.run(TestStep.java:79)
	at cucumber.api.TestCase.run(TestCase.java:58)
	at cucumber.runner.Runner.runPickle(Runner.java:80)
	at cucumber.runtime.Runtime.runFeature(Runtime.java:119)
	at cucumber.runtime.Runtime.run(Runtime.java:104)
	at cucumber.runtime.Runtime$run.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
	at SerenityMain.run(SerenityMain.groovy:41)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
	at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151)
	at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:102)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:55)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:197)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:217)
	at SerenityMain.main(SerenityMain.groovy:26)```
@kutzi
Copy link
Contributor Author

kutzi commented Jul 4, 2018

Will downgrade and check if the error really disappears

@wakaleo
Copy link
Member

wakaleo commented Jul 4, 2018

Could you check with 1.9.28 and 1.9.10 to see if the error disappears? 1.9.28 is built with cucumber 3.0.0. Failing that, I will roll back the 3.0.0 upgrade.

@cliviu
Copy link
Collaborator

cliviu commented Jul 4, 2018

hi @kutzi , please provide also a small project to reproduce the issue. How are you running the tests ?

@kutzi
Copy link
Contributor Author

kutzi commented Jul 4, 2018

@cliviu sorry, but that would be very much down on my priority list to provide a test project. So don't expect there anythig soon

@kutzi
Copy link
Contributor Author

kutzi commented Jul 4, 2018

 private static byte run(String[] argv, ClassLoader classLoader) throws IOException {
        RuntimeOptions runtimeOptions = new RuntimeOptions(new ArrayList<String>(asList(argv)))

        ResourceLoader resourceLoader = new MultiLoader(classLoader)
        Configuration systemConfiguration = Injectors.getInjector().getInstance(Configuration.class)
        Runtime runtime = CucumberWithSerenity
                .createSerenityEnabledRuntime(resourceLoader, classLoader, runtimeOptions, systemConfiguration)
        runtime.run()
        return runtime.exitStatus()
    }

That's how we start Serenity.
If you have any specific question, please let me know.

To create a compehensive, small project to reproduce the issue - I currently lack the time for that. Sorry

@wakaleo
Copy link
Member

wakaleo commented Jul 4, 2018

@kutzi is there a reason you are not running the tests through Maven or Gradle?

@cliviu
Copy link
Collaborator

cliviu commented Jul 4, 2018

@kutzi your way of starting Serenity will not work anymore with the new version. I will take a look to see if I can find an alternative

@mrcjbf
Copy link

mrcjbf commented Jul 11, 2018

did anyone figure out this error yet? I am still running into it. I have tried everything in this thread and every link I can find online and I can't make any progress. in the class StepEventBus.class, this method, the baseStepListener is always null:

public void updateOverallResults() {
this.baseStepListener.updateOverallResults();
}

java.lang.NullPointerException
at net.thucydides.core.steps.StepEventBus.updateOverallResults(StepEventBus.java:686)
at net.serenitybdd.screenplay.EventBusInterface.updateOverallResult(EventBusInterface.java:29)
at net.serenitybdd.screenplay.Actor.perform(Actor.java:115)
at net.serenitybdd.screenplay.Actor.attemptsTo(Actor.java:86)
at net.serenitybdd.screenplay.Actor.has(Actor.java:73)

@wakaleo
Copy link
Member

wakaleo commented Jul 11, 2018

Are you running the tests with the Serenity runner?

@mrcjbf
Copy link

mrcjbf commented Jul 11, 2018

I am using a test runner file

@wakaleo
Copy link
Member

wakaleo commented Jul 11, 2018

Are you trying to run the tests with TestNG?

@mrcjbf
Copy link

mrcjbf commented Jul 11, 2018

yes. I'm trying to set them up to run nightly through jenkins, and I am getting some guidance from another dev at my job, and he said all I need to do is figure out how to run the features by running that testng xml file

@wakaleo
Copy link
Member

wakaleo commented Jul 11, 2018

Serenity doesn’t support TestNG

@mrcjbf
Copy link

mrcjbf commented Jul 11, 2018

no way really? no wonder I haven't been able to figure it out. do you know if there is a way to run the features in a similar way, from an xml file through jenkins, using junit?

@wakaleo
Copy link
Member

wakaleo commented Jul 11, 2018

Just don’t extend the TestNG base class and run with the JUnit runner insteas

@kutzi
Copy link
Contributor Author

kutzi commented Jul 12, 2018

Back to the original issue: @cliviu did you already manage to find a new way how I could run it?

@cliviu
Copy link
Collaborator

cliviu commented Jul 12, 2018

@kutzi currently we have switched back to Cucumber 2.x.x

@kutzi
Copy link
Contributor Author

kutzi commented Jul 12, 2018

That means that it should work again?

@cliviu
Copy link
Collaborator

cliviu commented Jul 12, 2018

Yes, with 1.9.30/1.9.12

@kutzi
Copy link
Contributor Author

kutzi commented Jul 13, 2018

I upgraded to 1.9.30/1.9.12 and immediately encountered the issue again

@wakaleo
Copy link
Member

wakaleo commented Jul 13, 2018

Can you provide a sample project? We are not seeing this problem locally.

@kutzi
Copy link
Contributor Author

kutzi commented Jul 13, 2018

Sorry, but I probably won't find the time to provide a sample project sometime soon

@kutzi
Copy link
Contributor Author

kutzi commented Jul 13, 2018

What I don't get from the reading code: is the baseStepListener optional or not?
That seems to hint that it's optional

/**
     * A reference to the base step listener, if registered.
     */
    private BaseStepListener baseStepListener;

but in the codepath from the stacktrace it's not handled as this, i.e. getBaseStepListener() is called without checking isBaseStepListenerRegistered() first

@kutzi
Copy link
Contributor Author

kutzi commented Jul 13, 2018

I found out that this always, consistently happens for the same feature file. I'll share the content of the file - stripped from all potential confidential content - in case it helps:

Feature:
    Make sure that the xyz rewrite rules still work.
    Description: a
    b
    c
    d

  Scenario Outline: Test if the rewrite anchor points are still present on a Ticket Page
    Given the customer opens the <TicketPage>
    Then validate that in the bodyElement the marker attribute mainBody is present

# TODO: adapt and re-enable these tests:
#    Then ensure that the stickyPricebarDiv contains the sticky-pricebar class attribute
#    Then ensure that the countDownDiv contains the coundown class attribute


    Examples:
    |TicketPage|
    |games.APage|
    |games.BPage|
    |games.CPage|
    |games.DPage|

@wakaleo
Copy link
Member

wakaleo commented Jul 14, 2018

If baseStepListener is null, your test hasn't set up Serenity correctly. If you are starting Serenity using custom logic as mentioned above, you may run into problems if the internal Serenity or Cucumber APIs change. However if this is a case, this isn't a Serenity defect but rather a usage error. We could help with this as part of one of the professional support packages (https://johnfergusonsmart.com/serenity-bdd-mentoring/) if you need further help.

I don't see anything odd in the Feature file though.

@cliviu
Copy link
Collaborator

cliviu commented Jul 16, 2018

@kutzi, the problem is that after "Feature:" you need to start with the feature description. The problem is that you start with the feature description on the next line.

@cliviu
Copy link
Collaborator

cliviu commented Jul 16, 2018

see here the gherkin doc https://docs.cucumber.io/gherkin/reference/

@kutzi
Copy link
Contributor Author

kutzi commented Jul 18, 2018

Thanks @cliviu, that did the trick!
Note that this did work before (in 1.9.17), but as you pointed out, this syntax was never allowed, so I wouldn't call it a regression.

@kutzi kutzi closed this as completed Jul 18, 2018
@erdelyizsolt
Copy link

I don`t know if it is late, but try to write your feature description right after Feature: keyword...not with an Enter below...yes it is odd, but I countered with the same issue, and that was the solution...

@wakaleo
Copy link
Member

wakaleo commented Mar 6, 2020

That's the Gherkin syntax

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

5 participants