【问题标题】:Kotest: disable test with reason in FreeSpecKotest:在 FreeSpec 中有原因地禁用测试
【发布时间】:2023-02-05 22:52:24
【问题描述】:

我正在尝试将以前用 Junit 编写的一些测试转换为 kotest。 我需要使用 FreeSpec 样式。

但是,我找不到一个好的方法(不是在文档中,也不是在尝试了几个小时之后)来禁用测试并说明它被禁用的原因。

我想采用以前使用 Junit 编写的这部分代码:

class myTest {
    
    @Ignored("The test should be ignored")
    @Test
    fun `my ignored test`() {}
} 

进入测试:

class myTest: FreeSpec( {
    
    <Ignore with a reason>
    "my ignored test" {}
})

不幸的是,@ignore注释(kotest)不排除任何原因消息。

有谁知道如何通过提供理由来忽略测试?

谢谢

【问题讨论】:

    标签: kotlin kotest


    【解决方案1】:

    您可以在测试名称上使用 .config。

    class myTest: FreeSpec( {
        
        "my ignored test".config(enabledOrReasonIf = ....) {}
    })
    

    【讨论】:

      猜你喜欢
      • 2022-08-11
      • 2023-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-29
      • 1970-01-01
      • 2020-11-13
      相关资源
      最近更新 更多