gauge icon indicating copy to clipboard operation
gauge copied to clipboard

Steps implemented in Kotlin are not recognised from command line

Open BugDiver opened this issue 7 years ago • 9 comments

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

  1. Create a gauge project in IntelliJ.
  2. Create a new step and implement it in Kotlin.
  3. Execute specs from IntelliJ. (works fine)
  4. 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

BugDiver avatar Aug 31 '17 05:08 BugDiver

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 avatar Nov 28 '17 21:11 martypitt

@martypitt Thanks for posting your findings.

BugDiver avatar Nov 29 '17 05:11 BugDiver

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 avatar Apr 18 '19 08:04 dihnatsyeu

@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 ?

NivedhaSenthil avatar Apr 18 '19 09:04 NivedhaSenthil

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.

sriv avatar Apr 19 '19 00:04 sriv

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.

sriv avatar Apr 19 '19 00:04 sriv

Any chance to use Kotlin in Gauge? Is it on the roadmap?

edpichler avatar Feb 16 '20 16:02 edpichler

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.

zabil avatar Feb 17 '20 13:02 zabil

Interesting thing is that Kotlin implementation works with older versions of the java plugin

coding-lama avatar Mar 04 '20 16:03 coding-lama