I use Awaitility to poll my REST tasks. But when I call the Task inside the Callable interface, I get java.lang.NullPointerException at
java.lang.NullPointerException
at net.thucydides.core.steps.StepEventBus.updateOverallResults(StepEventBus.java:706)
The Serenity Task works fine if called without the Callable interface. It seems like if Serenity Task is called through Callable interface, it couldn't figure out the baseStepListener in the StepEventBus class.
My sample code is below,
```
private int someTask()
{
when( Fred ).attemptsTo(WaitUntil.the(SomePage.SUB_TITLE, WebElementStateMatchers.isCurrentlyVisible()));
//rest of the code goes below//
return 0;
}
@Test
public void awaitTest()
{
await().atMost( 300, TimeUnit.SECONDS )
.pollInterval( 3, TimeUnit.SECONDS )
.until( () -> someTask() > 1);
}
```
Awaitility runs the task in a separate thread, without knowledge of the Serenity context, so this won't work. I will have a look at extending the existing WaitFor tasks for this purpose.
@wakaleo do you have any workaround?
@gkushang - You may try
Awaitility.await().pollInSameThread()...
Thanks @justinhinze, I wasn鈥檛 aware of that feature.
Most helpful comment
@gkushang - You may try
Awaitility.await().pollInSameThread()...