Issue
I would like to use existing step definition classes coming from maven jar dependency.
My cucumber tests works if ran from Runner Class (with glue to packages) & mvn CLI. But the problem is with IntelliJ Cucumber plugin for the steps which are coming from jar. In feature file steps that I am using from the jar are shown as "Undefined step reference:...". I am not even able to run directly from feature file.
Is there a way I can configure cucumber plugin to use stepdefinations from classloader/jar?
Solution
Posting the solution worked for Me:
- Use IntelliJ 2020.1 +
- In cucumber run configuration : select jar manifest for classpath
- Deploy the Jar with source jar as well to Nexus as below
You can simple do this by adding maven-source-plugin
plugin to your build
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
- In other project add dependency and confirm source is downloaded from repo
File -> Project Structure -> Libraries -> Select the Artifact -> Sources , Make sure it's not in red.
- Update IntelliJ to use latest version, for me IntelliJ version 2019 did not work but 2020.1 was able to find the step definitions.
PS: I use Java8 with Lambda exp and I can confirm it works.
Answered By - Vikas Thange
Answer Checked By - Marie Seifert (JavaFixing Admin)