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.util.concurrent.ExecutionException: java.lang.NullPointerException: No BaseStepListener has been registered : Throwing this exception under Java's Callable interface call() method with Serenity #2203

Closed
nitin1989 opened this issue Aug 16, 2020 · 5 comments

Comments

@nitin1989
Copy link

nitin1989 commented Aug 16, 2020

Hi ,
I am getting below exception on using Callable interface call() method implemetation with Serenity.

java.util.concurrent.ExecutionException: java.lang.NullPointerException: No BaseStepListener has been registered
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at com.serenity.test.cucumberStepDefinitions.api.EmployeeGlue.i_hit_API_n_times_with_body_data_as(EmployeeGlue.java:125)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at cucumber.runtime.Utils$1.call(Utils.java:26)
at cucumber.runtime.Timeout.timeout(Timeout.java:16)
at cucumber.runtime.Utils.invoke(Utils.java:20)

Below is the code I am using inside Callable interface's call() method:

@OverRide
public String call() throws Exception
{
Response res=null;
StringBuilder sb = new StringBuilder();
res=employee.createNewEmployee(url,payload); // Calling to POST API to create employees
JsonPath jsonpath = res.jsonPath();
String name = jsonpath.get("name");
sb.append("API Response : ").append(res.asString()).append('\n');
sb.append("Name : ").append(name).append('\n');
Serenity.recordReportData().withTitle("Employee Creation : ").andContents(sb.toString()); // Exception thrown here.
return name;

}

Exception is getting thrown in above code when logging content in Serenity report(Line of code highlighted above in bold)

@wakaleo
Copy link
Member

wakaleo commented Aug 16, 2020

You are using Serenity in a separate thread - that won’t work.

@nitin1989
Copy link
Author

Why is this so?

@wakaleo
Copy link
Member

wakaleo commented Aug 16, 2020

The Serenity reporter is thread local and tied to a particular thread.

@nitin1989
Copy link
Author

Ok. Is there any workaround for logging the content in Serenity report, since its not even logging the API request and response in Serenity report on using SerenityRest class within Callable implementation.

@wakaleo
Copy link
Member

wakaleo commented Aug 18, 2020

You would need to look at the code to figure out a way to do this.

@wakaleo wakaleo closed this as completed Feb 12, 2022
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

No branches or pull requests

2 participants