Home > Back-end >  Kotlin karate-junit-5 no features or scenarios found
Kotlin karate-junit-5 no features or scenarios found

Time:09-24

I'm using karate with junit-5 runner and kotlin and karate doesn't seem to find my feature files :

I get the following

no features or scenarios found: [classpath:sncf/karate] org.opentest4j.AssertionFailedError: no features or scenarios found: [classpath:sncf/karate]

Here is my test file:

package sncf.karate

import com.intuit.karate.junit5.Karate

class ThreatControllerIT {

   @Karate.Test
   fun testThreat(): Karate {
       return Karate.run().relativeTo(javaClass)
   }
}

and my tree from the it package (where I store my integration tests)

kotlin
│   ├── karate-config.js
│   └── sncf
│      └── karate
│          ├── ThreatController.feature
│          └── ThreatControllerIT.kt
└── resources

CodePudding user response:

Thanks for the help,

I created another test type for integration test and my config was wrong at the build.gradle.kts, following this link https://github.com/intuit/karate#folder-structure helped me a lot.

Here's my final build.gradle.kts configuration for my integration tests

sourceSets {
    create("it") {
        compileClasspath  = sourceSets.main.get().output
        runtimeClasspath  = sourceSets.main.get().output

        resources {
            srcDir(file("src/it/kotlin"))
            exclude("**/*.kt")
        }
    }
}

CodePudding user response:

I did a Google search and found some Kotlin Karate projects, so maybe that helps: TestKarate.kt.

Else this is not something the project developers have spent time on, so perhaps you can contribute :)

That said, note that using JUnit is not mandatory, and you may have better results with the Runner API: https://stackoverflow.com/a/65578167/143475

A common mistake is to not use the recommended Maven structure: https://github.com/intuit/karate#folder-structure

  • Related