gauge
gauge copied to clipboard
Steps implemented in Kotlin are not recognised from command line
Expected behavior
The behavior should be same for IDE and command line
Actual behavior
Steps implemented in Kotlin instead of java works fine from IntelliJ but from command line getting Steps Implementation not found
.
Steps to reproduce
- Create a gauge project in IntelliJ.
- Create a new step and implement it in Kotlin.
- Execute specs from IntelliJ. (works fine)
- Execute specs from the command line.
Gauge version
Gauge version: 0.9.1
Plugins
-------
html-report (4.0.2)
java (0.6.4)
Referance Project : kotlinProject.zip
Kotlin compiled steps seem to work fine if executed by the maven plugin.
Here's my pom.xml
:
<dependencies>
<dependency>
<groupId>com.thoughtworks.gauge</groupId>
<artifactId>gauge-java</artifactId>
<version>0.6.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.thoughtworks.gauge.maven</groupId>
<artifactId>gauge-maven-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<phase>test</phase>
<configuration>
<specsDir>specs</specsDir>
</configuration>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
@martypitt Thanks for posting your findings.
It seems that not a good fix for the issue that exists. I would like to able to run gauge tests with kotlin steps implementation. Is it possible?
@dihnatsyeu official support for kotlin is yet to be added in gauge to make things work out of box... have you tried using maven plugin like mentioned in above comment ?
Some additional context that might help - the gauge-java plugin is specific to java, i.e. it can only compile java code since it uses the javac
compiler.
It's worth noting that -
- gauge-java compiles the test code before start of execution
- gauge-java reflects on the compiled jar to gather step implementations and uses reflection to invoke the step methods.
The 2nd point above enables gauge-java to be used with any jvm based language, but there are limitations mostly on authoring support. Execution should still be possible. Ex. see gauge groovy example which runs with gauge-java plugin.
The trick is to add a step to compile the code (in this case Kotlin) and do one of the below:
- set the compiler output to be
$PROJECT_ROOT/gauge_bin
- or set the
gauge_custom_build_path
to be the location of the compiled jar.
This should be possible without a build tool (maven/gradle) but I guess if you are using these for dependency management, you might as well use them for bootstrapping the compile step.
Reopened this as a feature request for more seamless Kotlin support.
Dev notes:
-
this could potentially be extended to any JVM language. There has been request for groovy and clojure before.
-
Executing a kotlin/clojure/groovy project should be relatively easier.
-
adding editing support, IDE plugins etc would require a bigger effort.
Any chance to use Kotlin in Gauge? Is it on the roadmap?
A feature to make it support JVM languages will be added. But there won't be official support for Kotlin expecially for IDE's.
This will be a part of Gauge 2.0 which will be released later this year.
Interesting thing is that Kotlin implementation works with older versions of the java plugin