I’ve noticed some matcher functions handle nullabl...
# kotest
I’ve noticed some matcher functions handle nullable variables but other’s don’t e.g. this works for a `String?`:
Copy code
testString shouldHaveMinLength 1
But it doesn’t work for a `Int?`:
Copy code
testInt shouldBeGreaterThan 0
The error is -
Infix call corresponds to a dot-qualified call 'testInt.shouldBeGreaterThan(0)' which is not allowed on a nullable receiver 'testInt'. Use '?.'-qualified call instead
So I can get around it by doing this:
Copy code
Is this a limitation of Kotest and is there a better way I can handle this?
You can do
Alternatively, we can make some matchers work on nulls and do that for you
Thanks I’ll try that, but yes it would be good if other matchers could handle nullable 👍