zerocode icon indicating copy to clipboard operation
zerocode copied to clipboard

[1.3.28] Step "assertions" field is not null safe

Open infoShare opened this issue 4 years ago • 6 comments

Is it possible to make Step.assertions field null safe ? We're using tests on spring boot and with version changed from 2.5.4 to 2.6.1 we're receiving NPE on Step constructor. JsonNode assertions was previously always not null - now it's null.

this.assertions = assertions.isNull() ? verify : assertions;

infoShare avatar Dec 08 '21 13:12 infoShare

@infoShare can you share the step that's producing NPE?

sparrowV avatar Dec 17 '21 16:12 sparrowV

Try to use framework with jackson-databind 2.13.0

You'll receive this error for steps that doesn't contains assertions: Caused by: java.lang.NullPointerException at org.jsmart.zerocode.core.domain.Step.(Step.java:154)

Assertions here is null: this.assertions = assertions.isNull() ? verify : assertions; and with previous jackson versions was always not null (NullNode with 'null' value).

infoShare avatar Dec 20 '21 10:12 infoShare

@infoShare you can specify empty assertions block. assertions : {} It should help with NPE

sparrowV avatar Dec 20 '21 10:12 sparrowV

but what is the point of adding additional assertions: {} next to the verify which can be used ?

infoShare avatar Dec 20 '21 11:12 infoShare

@infoShare I understand now. I agree this should be null safe. For a workaround, make sure that during test phase, it uses old jackson-databind(that comes from zerocode), not new one.

sparrowV avatar Dec 20 '21 12:12 sparrowV

@infoShare this is a known issue in jackson-core for more inforamtion please refer to this lik. https://github.com/FasterXML/jackson-databind/issues/3214

chou3ib1 avatar Jan 22 '22 15:01 chou3ib1