【问题标题】:Kotlintest - Unresolved reference shouldMatchJsonKotlintest - 未解决的参考 shouldMatchJson
【发布时间】:2019-11-14 01:13:09
【问题描述】:

似乎我无法从 Kotlintest v3.4.2 访问 shouldMatchJson 匹配器,方法记录在 https://github.com/kotlintest/kotlintest/blob/master/doc/matchers.md 中。 我得到未解决的参考,我似乎无法导入它。代码说它是 String 类的扩展方法,但尝试使用字符串甚至 """{}""" 但无法访问该方法。难道我做错了什么?其他所有匹配器都正常。

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

【问题讨论】:

    标签: testing kotlin kotlintest


    【解决方案1】:

    可能是您缺少 json 扩展的导入吗?

    我的 build.gradle 中有这个:

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

    【讨论】:

    • 非常感谢。我试图搜索这个,即使在文档中也找不到它。我想知道为什么自述文件没有说或者我错过了。
    猜你喜欢
    • 1970-01-01
    • 2019-04-05
    • 1970-01-01
    • 2021-08-17
    • 2016-12-14
    • 2020-05-27
    • 2019-11-16
    • 2021-01-24
    • 2023-03-25
    相关资源
    最近更新 更多