简体   繁体   English

如何使用 kotest/kotlintest 在上下文中运行单个测试

[英]How to run a single test in a context using kotest/kotlintest

I have the following test suite:我有以下测试套件:

class FooTest : FunSpec() {
    init {
        context("a context") {
            test("first test") {
                true shouldBe false
            }

            test("f:second test") {
                true shouldBe true
            }
        }
    }
}

I try to execute it in IntelliJ Idea.我尝试在 IntelliJ Idea 中执行它。 Unfortunately it executes both test in the suite.不幸的是,它在套件中执行了两个测试。 It works well if I don't nest the test in context() .如果我不在context()嵌套测试,它会很好地工作。

There is an IntelliJ plugin which provide features to run a single test and many more features.有一个IntelliJ 插件,它提供运行单个测试的功能和更多功能。

Using this plugin, if you click the run/play icon on line 3 (context) it will run the context + the nested tests.使用此插件,如果您单击第 3 行(上下文)上的运行/播放图标,它将运行上下文 + 嵌套测试。 If you click run on line 4 or line 8 it will run context + the test you clicked on.如果您在第 4 行或第 8 行单击运行,它将运行上下文 + 您单击的测试。 Focus does not work on nested tests as per the docs 根据文档,焦点不适用于嵌套测试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用KotlinTest库在测试方法中验证模拟接口? - How to verify a mock interface in a test method using KotlinTest library? 使用 springmockk 时 Kotlintest 不执行测试 - Kotlintest not executing test when using springmockk 如何在ruby Test :: Unit框架中运行单个shoulda上下文测试 - How to run a single shoulda context test in ruby Test::Unit framework 如何使用 Kotest 和 Mockk 库为返回 LiveData 的方法编写单元测试 - How to write unit test for the method returns LiveData with Kotest and Mockk library 如何使用 Unit::Test 在 Ruby on Rails 3.0.7 中运行单个测试? - How to run a single test in Ruby on Rails 3.0.7 using Unit::Test? Autotools:如何使用make check运行单个测试? - Autotools: How to run a single test using make check? 如何使用 Gradle 命令在 Android 中运行单个测试类? - How to run single test class in Android using Gradle command? 如何使用Gradle在grails-core项目中运行单个测试? - How to run single test in grails-core project using Gradle? 如何使用Selenium连续运行一个测试用例? - How do I continuously run a single test case using Selenium? 如何使用Kotlin运行单个Android测试? - How can I run a single Android Test using Kotlin?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM