Kotlintest - Unresolved reference shouldMatchJson

574 Views Asked by At

Seems like I can't access shouldMatchJson matcher from Kotlintest v3.4.2 the way is documented in https://github.com/kotlintest/kotlintest/blob/master/doc/matchers.md. I get unresolved reference and I seem unable to import it. The code says it's an extension method to String class but tried with strings and even """{}""" but can't access that method. Am I doing something wrong? All other matchers are ok.

class Test : StringSpec ({
    "Test a json" {
        "{}".shouldMatchJson("{}")
    }
})

unresolved reference

1

There are 1 best solutions below

1
On

Could it be that you are missing the import for the json extension?

I have this in my build.gradle:

testImplementation "io.kotlintest:kotlintest-assertions-json:3.4.2"