Skip to content

Latest commit

 

History

History
40 lines (34 loc) · 1.09 KB

kotest-snippets.md

File metadata and controls

40 lines (34 loc) · 1.09 KB

Kotest Snippets

Code snippets employed to ensure the uniformity of tests written with Kotest library.

1. Use Case Test

class UseCaseTest : FreeSpec({
    "UseCase has test class" {
        Konsist
            .scopeFromProject()
            .classes()
            .withNameEndingWith("UseCase")
            .assertTrue(testName = this.testCase.name.testName) { it.hasTestClass() }
    }
})

2. Use Case Tests

class UseCaseTests : FreeSpec({
    Konsist
        .scopeFromProject()
        .classes()
        .withNameEndingWith("UseCase")
        .forEach { useCase ->
            "${useCase.name} should have test" {
                useCase.assertTrue(testName = this.testCase.name.testName) { it.hasTestClass() }
            }
            "${useCase.name} should reside in ..domain..usecase.. package" {
                useCase.assertTrue(testName = this.testCase.name.testName) { it.resideInPackage("..domain..usecase..") }
            }
            "${useCase.name} should ..." {
                // another Konsist assert
            }
        }
})