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

[Serenity Junit 5 ]: No BaseStepListener has been registered - are you running your test using the Serenity runners? #2790

Closed
bachhavdipak opened this issue Apr 21, 2022 · 18 comments

Comments

@bachhavdipak
Copy link
Contributor

bachhavdipak commented Apr 21, 2022

[serenityCoreVersion = 3.2.0]

Getting below exception while running Junit 5 api test.

Code:

package test;


import net.serenitybdd.junit5.SerenityJUnit5Extension;
import net.serenitybdd.junit5.SerenityTest;
import net.thucydides.core.annotations.Steps;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
import org.junit.jupiter.params.provider.CsvSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


@ExtendWith(SerenityJUnit5Extension.class)
@DisplayNameGeneration(Data.DisplayNameGenerator.class)
public class APIRequest {

    private static final Logger logger = LoggerFactory.getLogger(APIRequest.class);
  

    @Steps
    UserGroup userGroup;

    
    @ParameterizedTest
    @CsvSource({
            "454545,date=20180131, 456456456",
            "454534, valid=5, 456456456"

    })
     public void responseMessage(String value, String criteria, String output) {
        userGroup.getRequest("au", value, criteria);
        userGroup.outputResponse(output);
    }
}

Error:

NO BASE STEP LISTENER FOUND IN THREAD Thread[ForkJoinPool-1-worker-1,5,main]
Apr 21, 2022 9:36:36 AM org.junit.platform.launcher.core.CompositeTestExecutionListener lambda$notifyEach$19
WARNING: TestExecutionListener [net.serenitybdd.junit5.SerenityTestExecutionListener] threw exception for method: executionFinished(TestIdentifier [uniqueId = [engine:junit-jupiter]/[class:platform.services.uat_public_au.CAB_APIRequests]/[test-template:responseMessage(java.lang.String, java.lang.String, java.lang.String)]/[test-template-invocation:#1], parentId = [engine:junit-jupiter]/[class:platform.services.uat_public_au.CAB_APIRequests]/[test-template:responseMessage(java.lang.String, java.lang.String, java.lang.String)], displayName = '[1] 30515949, validity_from_date=20180131, 30766686', legacyReportingName = 'responseMessage(String, String, String)[1]', source = MethodSource [className = 'platform.services.uat_public_au.CAB_APIRequests', methodName = 'responseMessage', methodParameterTypes = 'java.lang.String, java.lang.String, java.lang.String'], tags = [API, au, CAB_APIRequests-uat_public-V0-AU], type = TEST], TestExecutionResult [status = FAILED, throwable = java.lang.NullPointerException: No BaseStepListener has been registered - are you running your test using the Serenity runners?])
java.lang.NullPointerException: No BaseStepListener has been registered - are you running your test using the Serenity runners?
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:907)
	at net.thucydides.core.steps.StepEventBus.getBaseStepListener(StepEventBus.java:153)
	at net.serenitybdd.junit5.SerenityTestExecutionListener.testFinished(SerenityTestExecutionListener.java:335)
	at net.serenitybdd.junit5.SerenityTestExecutionListener.executionFinished(SerenityTestExecutionListener.java:277)
	at org.junit.platform.launcher.core.CompositeTestExecutionListener.lambda$executionFinished$10(CompositeTestExecutionListener.java:69)
	at org.junit.platform.launcher.core.CompositeTestExecutionListener.lambda$notifyEach$19(CompositeTestExecutionListener.java:95)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at org.junit.platform.launcher.core.CompositeTestExecutionListener.notifyEach(CompositeTestExecutionListener.java:93)
	at org.junit.platform.launcher.core.CompositeTestExecutionListener.executionFinished(CompositeTestExecutionListener.java:69)
	at org.junit.platform.launcher.core.ExecutionListenerAdapter.executionFinished(ExecutionListenerAdapter.java:56)
	at org.junit.platform.launcher.core.DelegatingEngineExecutionListener.executionFinished(DelegatingEngineExecutionListener.java:46)
	at org.junit.platform.launcher.core.OutcomeDelayingEngineExecutionListener.executionFinished(OutcomeDelayingEngineExecutionListener.java:63)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.reportCompletion(NodeTestTask.java:195)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:100)
	at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:185)
	at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService.submit(ForkJoinPoolHierarchicalTestExecutorService.java:118)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask$DefaultDynamicTestExecutor.execute(NodeTestTask.java:226)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask$DefaultDynamicTestExecutor.execute(NodeTestTask.java:204)
	at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:139)
	at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$2(TestTemplateTestDescriptor.java:107)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
	at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
	at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
	at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:107)
	at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:42)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:185)
	at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService.invokeAll(ForkJoinPoolHierarchicalTestExecutorService.java:129)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:185)
	at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService.invokeAll(ForkJoinPoolHierarchicalTestExecutorService.java:129)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:185)
	at java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:189)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1067)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1703)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:172)


No BaseStepListener has been registered - are you running your test using the Serenity runners?
java.lang.NullPointerException: No BaseStepListener has been registered - are you running your test using the Serenity runners?
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:907)
	at net.thucydides.core.steps.StepEventBus.getBaseStepListener(StepEventBus.java:153)
	at net.serenitybdd.junit5.SerenityJUnit5Extension.lambda$beforeEach$1(SerenityJUnit5Extension.java:59)
	at java.util.Optional.ifPresent(Optional.java:159)
	at net.serenitybdd.junit5.SerenityJUnit5Extension.beforeEach(SerenityJUnit5Extension.java:57)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$2(TestMethodTestDescriptor.java:163)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:199)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:199)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:162)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:129)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:185)
	at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService.submit(ForkJoinPoolHierarchicalTestExecutorService.java:118)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask$DefaultDynamicTestExecutor.execute(NodeTestTask.java:226)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask$DefaultDynamicTestExecutor.execute(NodeTestTask.java:204)
	at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:139)
	at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$2(TestTemplateTestDescriptor.java:107)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
	at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
	at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
	at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:107)
	at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:42)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:185)
	at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService.invokeAll(ForkJoinPoolHierarchicalTestExecutorService.java:129)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:185)
	at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService.invokeAll(ForkJoinPoolHierarchicalTestExecutorService.java:129)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:185)
	at java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:189)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1067)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1703)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:172)
	Suppressed: java.lang.NullPointerException: No BaseStepListener has been registered - are you running your test using the Serenity runners?
		at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:907)
		at net.thucydides.core.steps.StepEventBus.getBaseStepListener(StepEventBus.java:153)
		at net.serenitybdd.junit5.SerenityJUnit5Extension.afterEach(SerenityJUnit5Extension.java:36)
		at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterEachCallbacks$12(TestMethodTestDescriptor.java:257)
		at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$13(TestMethodTestDescriptor.java:273)
		at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
		at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$14(TestMethodTestDescriptor.java:273)
		at java.util.ArrayList.forEach(ArrayList.java:1259)
		at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAllAfterMethodsOrCallbacks(TestMethodTestDescriptor.java:272)
		at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAfterEachCallbacks(TestMethodTestDescriptor.java:256)
		at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:141)
		... 80 more

@bachhavdipak bachhavdipak changed the title Getting java.lang.NullPointerException: No BaseStepListener has been registered - are you running your test using the Serenity runners? [Serenity Junit 5 ]: No BaseStepListener has been registered - are you running your test using the Serenity runners? Apr 21, 2022
@cliviu
Copy link
Collaborator

cliviu commented Apr 21, 2022

hi @bachhavdipak, are you running the tests in parallel?

@bachhavdipak
Copy link
Contributor Author

No, I am not running the test in parallel mode but trying to do POC for that purpose I have added junit-platform.properties file

junit.jupiter.execution.parallel.enabled=true
junit.jupiter.execution.parallel.config.strategy=dynamic

@cliviu
Copy link
Collaborator

cliviu commented Apr 25, 2022

junit.jupiter.execution.parallel.enabled=true enables the parallel mode. try with 3.2.4 please

@pogodins
Copy link
Contributor

pogodins commented May 4, 2022

Hi @cliviu, I'm getting the same with 3.2.4.
Do you have a working example for parallel tests execution with Junit5?
I see that you have an open PR #2732.

@cliviu
Copy link
Collaborator

cliviu commented May 4, 2022

hey @pogodins can you try please with
https://github.com/wakaleo/swaglabs-serenity-junit5
forget about that PR, its content is already merged

@pogodins
Copy link
Contributor

pogodins commented May 5, 2022

@cliviu, thanks for sharing repo! I checked it with Serenity 3.2.4.
Here are some comments:

  • Parallel classes work fine with the following settings:
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = same_thread
junit.jupiter.execution.parallel.mode.classes.default = concurrent
  • Base step listener issue is still reproducible for parallel methods within the class with the following settings:
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.mode.classes.default = concurrent

@cliviu
Copy link
Collaborator

cliviu commented May 5, 2022

@pogodins , very strange, I cannot reproduce it in my environment with the following settings

junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.mode.classes.default = concurrent

Can you please the log output when running in your environment (exceptions included) ?

@pogodins
Copy link
Contributor

pogodins commented May 5, 2022

Please find below my console output when running tests from https://github.com/wakaleo/swaglabs-serenity-junit5 with Maven and concurrent parallel methods and classes in JUnit:

[INFO] --- maven-failsafe-plugin:3.0.0-M4:integration-test (default) @ serenity-junit-starter ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running swaglabs.features.maths.WhenDoingSums
[INFO] Running swaglabs.features.travelling.WhenEarningFrequentFlyerPoints
[INFO] Running swaglabs.features.authentication.WhenLoggingOn
[INFO] Running swaglabs.features.shopping_cart.WhenManagingTheShoppingCart
[INFO] Running swaglabs.features.maths.WhenDoingSums$ABasicCalculator
[INFO] Running swaglabs.features.shopping_cart.WhenManagingTheShoppingCart$FromWithinTheProductPage
[INFO] Running swaglabs.features.shopping_cart.WhenManagingTheShoppingCart$FromTheShoppingCart
[ERROR] Tests run: 6, Failures: 0, Errors: 2, Skipped: 1, Time elapsed: 0.928 s <<< FAILURE! - in swaglabs.features.travelling.WhenEarningFrequentFlyerPoints
[ERROR] swaglabs.features.shopping_cart.WhenManagingTheShoppingCart$FromWithinTheProductPage.addSeveralItems  Time elapsed: 0.287 s  <<< ERROR!
java.lang.NullPointerException: No BaseStepListener has been registered - are you running your test using the Serenity runners?

[ERROR] swaglabs.features.shopping_cart.WhenManagingTheShoppingCart$FromWithinTheProductPage.addItem  Time elapsed: 0.398 s  <<< ERROR!
java.lang.NullPointerException: No BaseStepListener has been registered - are you running your test using the Serenity runners?

[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.929 s <<< FAILURE! - in swaglabs.features.shopping_cart.WhenManagingTheShoppingCart$FromTheShoppingCart
[ERROR] swaglabs.features.shopping_cart.WhenManagingTheShoppingCart$FromTheShoppingCart.viewItems  Time elapsed: 0.31 s  <<< ERROR!
java.lang.NullPointerException: No BaseStepListener has been registered - are you running your test using the Serenity runners?

Starting MSEdgeDriver 101.0.1210.32 (f7af80761c68124fe8e0fff52a5918d20448c1a4) on port 60762
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
MSEdgeDriver was started successfully.
Starting MSEdgeDriver 101.0.1210.32 (f7af80761c68124fe8e0fff52a5918d20448c1a4) on port 64503
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
MSEdgeDriver was started successfully.
Starting MSEdgeDriver 101.0.1210.32 (f7af80761c68124fe8e0fff52a5918d20448c1a4) on port 54432
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
MSEdgeDriver was started successfully.
May 05, 2022 11:53:15 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
May 05, 2022 11:53:15 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 101, so returning the closest version found: 99
May 05, 2022 11:53:15 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found CDP implementation for version 101 of 99
Starting MSEdgeDriver 101.0.1210.32 (f7af80761c68124fe8e0fff52a5918d20448c1a4) on port 60211
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
MSEdgeDriver was started successfully.
May 05, 2022 11:53:15 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
May 05, 2022 11:53:15 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 101, so returning the closest version found: 99
May 05, 2022 11:53:15 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found CDP implementation for version 101 of 99
Starting MSEdgeDriver 101.0.1210.32 (f7af80761c68124fe8e0fff52a5918d20448c1a4) on port 50179
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
MSEdgeDriver was started successfully.
May 05, 2022 11:53:17 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
May 05, 2022 11:53:17 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 101, so returning the closest version found: 99
May 05, 2022 11:53:17 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found CDP implementation for version 101 of 99
Starting MSEdgeDriver 101.0.1210.32 (f7af80761c68124fe8e0fff52a5918d20448c1a4) on port 59968
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
May 05, 2022 11:53:17 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
May 05, 2022 11:53:17 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 101, so returning the closest version found: 99
May 05, 2022 11:53:17 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found CDP implementation for version 101 of 99
MSEdgeDriver was started successfully.
Starting MSEdgeDriver 101.0.1210.32 (f7af80761c68124fe8e0fff52a5918d20448c1a4) on port 64507
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
MSEdgeDriver was started successfully.
May 05, 2022 11:53:18 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
May 05, 2022 11:53:18 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 101, so returning the closest version found: 99
May 05, 2022 11:53:18 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found CDP implementation for version 101 of 99
May 05, 2022 11:53:20 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
May 05, 2022 11:53:20 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 101, so returning the closest version found: 99
May 05, 2022 11:53:20 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found CDP implementation for version 101 of 99
May 05, 2022 11:53:21 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
May 05, 2022 11:53:21 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 101, so returning the closest version found: 99
May 05, 2022 11:53:21 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found CDP implementation for version 101 of 99
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 12.583 s - in swaglabs.features.shopping_cart.WhenManagingTheShoppingCart$FromWithinTheProductPage
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 12.594 s - in swaglabs.features.shopping_cart.WhenManagingTheShoppingCart
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 15.195 s - in swaglabs.features.authentication.WhenLoggingOn
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 15.672 s - in swaglabs.features.maths.WhenDoingSums$ABasicCalculator
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 15.686 s - in swaglabs.features.maths.WhenDoingSums
[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   WhenManagingTheShoppingCart$FromTheShoppingCart.viewItems » NullPointer No Bas...
[ERROR]   WhenManagingTheShoppingCart$FromWithinTheProductPage.addItem » NullPointer No ...
[ERROR]   WhenManagingTheShoppingCart$FromWithinTheProductPage.addSeveralItems » NullPointer
[INFO] 
[ERROR] Tests run: 14, Failures: 0, Errors: 3, Skipped: 1

As you can see only tests from a class with multiple @test methods are failing.

@cliviu
Copy link
Collaborator

cliviu commented May 5, 2022

thanks, do you also have the stack traces ?
you can use >> console.log 2>&1 for having the stack traces in the log

@cliviu
Copy link
Collaborator

cliviu commented May 5, 2022

and your pom.xml please

@pogodins
Copy link
Contributor

pogodins commented May 5, 2022

pom.xml contents:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>net.serenitybdd.starter</groupId>
    <artifactId>serenity-junit-starter</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Swaglabs Regression Test Suite</name>

    <properties>
        <serenity.version>3.2.4</serenity.version>
        <serenity.maven.version>3.2.4</serenity.maven.version>
        <junit5.version>5.8.2</junit5.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <encoding>UTF-8</encoding>
        <tags></tags>
        <parallel.tests>4</parallel.tests>
        <webdriver.base.url></webdriver.base.url>
    </properties>
    <dependencies>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-core</artifactId>
            <version>${serenity.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-junit5</artifactId>
            <version>${serenity.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-screenplay</artifactId>
            <version>${serenity.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-screenplay-webdriver</artifactId>
            <version>${serenity.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-ensure</artifactId>
            <version>${serenity.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.0.13</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.20</version>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>3.6.2</version>
            <scope>test</scope>
        </dependency>
        <!-- JUNIT 5 DEPENDENCY-->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit5.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit5.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M4</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.0.0-M4</version>
                <configuration>
                    <includes>
                        <include>**/*Test.java</include>
                        <include>**/Test*.java</include>
                        <include>**/*TestSuite.java</include>
                        <include>**/When*.java</include>
                        <include>**/features/**/*.java</include>
                    </includes>
                    <systemPropertyVariables>
                        <junit.jupiter.extensions.autodetection.enabled>true</junit.jupiter.extensions.autodetection.enabled>
                        <webdriver.base.url>${webdriver.base.url}</webdriver.base.url>
                    </systemPropertyVariables>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>16</source>
                    <target>16</target>
                    <compilerArgs>
                        <arg>-parameters</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.serenity-bdd.maven.plugins</groupId>
                <artifactId>serenity-maven-plugin</artifactId>
                <version>${serenity.maven.version}</version>
                <configuration>
                    <tags>${tags}</tags>
                </configuration>
                <executions>
                    <execution>
                        <id>serenity-reports</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>aggregate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

@pogodins
Copy link
Contributor

pogodins commented May 5, 2022

thanks, do you also have the stack traces ? you can use >> console.log 2>&1 for having the stack traces in the log

No additional traces are coming. I assume because of this line:

Preconditions.checkNotNull(currentListener, "No BaseStepListener has been registered - are you running your test using the Serenity runners?");

@cliviu
Copy link
Collaborator

cliviu commented May 5, 2022

ok, thank you, I will take a look to see if I can find a solution

@cliviu
Copy link
Collaborator

cliviu commented May 5, 2022

can you please try to run with mvn verify -Djunit.jupiter.execution.parallel.enabled=true, see if it improves anything?

cliviu added a commit to cliviu/serenity-core that referenced this issue May 5, 2022
@pogodins
Copy link
Contributor

pogodins commented May 6, 2022

@cliviu that option doesn't change anything for me.
Can I assume that you fixed the issue in #2810?

@cliviu
Copy link
Collaborator

cliviu commented May 6, 2022

yes, I hope that is fixed now, at least I could not reproduce it in my environment anymore

@pogodins
Copy link
Contributor

pogodins commented May 6, 2022

@cliviu, thanks for fixing!

I can confirm that it's working fine for me now with Serenity "3.2.6-SNAPSHOT" and the following JUnit config:

junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.mode.classes.default = concurrent

@cliviu
Copy link
Collaborator

cliviu commented May 6, 2022

Great, than maybe we should close the issue for now, right?

@cliviu cliviu closed this as completed May 6, 2022
wakaleo added a commit that referenced this issue Jun 1, 2022
* fix performance problem when choosing the right TestStrategyAdapter

* remove unused classes

* added support for @DisplayName , improve release notes

* delete not used releaseNotes file

* JUnit5: clearTestOutcomes at baseStepListener after generating report

* JUnit5: clearTestOutcomes at baseStepListener before starting test, fix @CsvSource with text block

* fix performance problem when choosing the right TestStrategyAdapter

* remove unused classes

* added support for @DisplayName , improve release notes

* delete not used releaseNotes file

* JUnit5: clearTestOutcomes at baseStepListener after generating report

* JUnit5: clearTestOutcomes at baseStepListener before starting test, fix @CsvSource with text block

* fix performance problem when choosing the right TestStrategyAdapter

* remove unused classes

* added support for @DisplayName , improve release notes

* delete not used releaseNotes file

* JUnit5: clearTestOutcomes at baseStepListener after generating report

* JUnit5: clearTestOutcomes at baseStepListener before starting test, fix @CsvSource with text block

* fix performance problem when choosing the right TestStrategyAdapter

* remove unused classes

* added support for @DisplayName , improve release notes

* delete not used releaseNotes file

* JUnit5: clearTestOutcomes at baseStepListener after generating report

* JUnit5: clearTestOutcomes at baseStepListener before starting test, fix @CsvSource with text block

* fix performance problem when choosing the right TestStrategyAdapter

* remove unused classes

* added support for @DisplayName , improve release notes

* delete not used releaseNotes file

* JUnit5: clearTestOutcomes at baseStepListener after generating report

* JUnit5: clearTestOutcomes at baseStepListener before starting test, fix @CsvSource with text block

* fix performance problem when choosing the right TestStrategyAdapter

* remove unused classes

* added support for @DisplayName , improve release notes

* delete not used releaseNotes file

* JUnit5: clearTestOutcomes at baseStepListener after generating report

* JUnit5: clearTestOutcomes at baseStepListener before starting test, fix @CsvSource with text block

* use @serenitybdd as marker for the JUnit5 Serenity managed tests

* removed not used class SerenityBDD

* fix junit-parallel merge problems

* upgrade to rest-assured 5.0.1

* fix junit5 parallel run issue #2790

* fix switching of report terminology

more standard use of "scenarios" and "test cases".

Co-authored-by: Liviu Carausu <l.carausu@znt.de>
Co-authored-by: John Ferguson Smart <john.smart@wakaleo.com>
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

4 participants