Error in running Cucumber test written using intellij, gradle and kotlin from the command line

Viewed 19

I am having difficulty in running a cucumber test from the command line using kotlin, gradle, and intellij. It appears there is a package path being injected by gradle. But I'm not sure. I am trying out kotlin, gradle, and intellj. It's an experiment to try a different environment. I've checked on the web for answers, but I can't really see something that applies.

What I want to do is run the test standalone. When I run it on the command line (see below), I get an errors such as:

WARNING: Failed to load class 'build.classes.kotlin.main.Command'.

This suggests that the classes are compiled into a package. There are no packages in any source files.

I have feature file for Cucumber that runs fine in the IDE.

The file layout: For classes

build/classes/kotlin/main  
build/classes/kotlin/test 

for source:

src/main/kotlin 
src/test/kotlin 

The root directory for the project is C:\Users\KenV1\IdeaProjects\GameWithCucumber

Here's the run.bat that I wrote. All the jarfiles have been copied into the jarfiles directory to simplify the path.

 set THISPATH="C:\Users\KenV1\IdeaProjects\jarfiles\*;.;C:\Users\KenV1\IdeaProjects\GameWithCucumber; C:\Users\KenV1\IdeaProjects\GameWithCucumber\build\classes\kotlin\main;C:\Users\KenV1\IdeaProjects\GameWithCucumber\build\classes\kotlin\test;"
    
    java -cp %THISPATH% org.junit.runner.JUnitCore  RunKukesTest

Running this results in:

JUnit version 4.13.2
Sep 11, 2022 9:53:59 PM io.cucumber.core.resource.ClasspathScanner safelyLoadClass
WARNING: Failed to load class 'build.classes.kotlin.main.Command'.
By default Cucumber scans the entire classpath for step definitions.
.... other notes
java.lang.NoClassDefFoundError: build/classes/kotlin/main/Command (wrong name: Command)

Command.class is located in build/classes/kotlin/main

And the error repeats for every class in main and test. Sometime the WARNING refers to classes.kotlin.main, rather than build.classes.kotlin.main

RunKukesTest.kt is:

import io.cucumber.junit.CucumberOptions
import org.junit.runner.RunWith
import io.cucumber.junit.Cucumber

@RunWith(Cucumber::class)
@CucumberOptions(
      features = [
            "C:\\Users\\KenV1\\IdeaProjects\\GameWithCucumber\\src\\test\\resources\\cucumber\\game.feature"]
)
class RunKukesTest

So why is build.classes.kotlin.main. being added to the class name? How can I prevent that?

Thanks.

0 Answers
Related