kotest / kotest-gradle-plugin

A gradle plugin for Kotest
https://kotest.io
Apache License 2.0
29 stars 5 forks source link

Wrong amount of Specs on the output #12

Closed alladywek closed 3 years ago

alladywek commented 3 years ago

Hi, I started to investigate this plugin and faced with an interesting thing, I have minimal project setup and found that Gradle produces the wrong amount of Specs in results. I have only 1 test file:

package testingstyles

import io.kotest.core.spec.style.StringSpec
import io.kotest.data.forAll
import io.kotest.data.row
import io.kotest.matchers.shouldBe
import kotlin.math.max

class StringSpecExampleTest : StringSpec() {
    init {
        "maximum of two numbers" {
            forAll(
                row(1, 5, 5),
                row(1, 0, 1),
                row(0, 0, 0)
            ) { a, b, max ->
                max(a, b) shouldBe max
            }
        }
    }
}

and build script:

plugins {
    kotlin("jvm") version "1.4.31"
    id("io.kotest") version "0.2.6"
}

group = "org.example"
version = "0.0.1"

val kotestVersion = "4.4.3"

repositories {
    mavenCentral()
}

tasks.withType<Test> {
    useJUnitPlatform()
}

dependencies {
    implementation(kotlin("stdlib"))
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3")
    testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
    testImplementation("io.kotest:kotest-framework-engine-jvm:$kotestVersion")
}

if you run Gradle command for tests ./gradlew clean kotest, than output is:

...
>> Kotest
- Feeding the kotest engine with freshly harvested tests
- Test plan has 2 specs

1.  io.kotest.core.script.ScriptSpec

2.  testingstyles.StringSpecExampleTest
    - maximum of two numbers OK

>> All tests passed

Specs:   2 passed, 0 failed, 2 total
Tests:   1 passed, 0 failed, 0 ignored, 1 total
Time:    0s

BUILD SUCCESSFUL in 2s
3 actionable tasks: 3 executed

The first test is from kotest itself 1. io.kotest.core.script.ScriptSpec but it should not be. Tested with Gradle wrapper version: 6.7 and 6.8.3

rezammalik commented 3 years ago

I actually noticed this as well.

sksamuel commented 3 years ago

ScriptSpec is a bug that crept into 4.4 and will be fixed in the 4.5 for April.

On Mon, 29 Mar 2021, 16:10 Reza Malik, @.***> wrote:

I actually noticed this as well.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kotest/kotest-gradle-plugin/issues/12#issuecomment-809716707, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGVTT3IU74EDGE3YWNTTGDUE3ANCNFSM42ANWC6Q .

sksamuel commented 3 years ago

See https://github.com/kotest/kotest/issues/2288