Intellij IDEA Run configurations for Cucumber runner class
Asked Answered
A

4

4

I am new to Intellij IDEA. I have a POM based cucumber-selenium project, where I've created cucumber runner classes for each feature file. While working with Eclipse I was able to execute these runner classes by Right click. However in Intellij IDEA (licensed version), even when cucumber-for-java and junit plugins are enabled in Settings window, I dont get Run option.

Also in Run/Debug configurations window -> Cucumber java -> what should be the main class? My main class has code to launch firefox browser and is in different subpackage.

If i mention "cucumber.cli.Main" in Main class, it gives me error - Could not find or load main class cucumber.cli.Main

Please help.

Thanks,

Anasarca answered 10/11, 2017 at 13:43 Comment(0)
A
10

Provided that cucumber support is enabled you should be able to run the test from .feature file's context menu: enter image description here

Also in Run/Debug configurations window -> Cucumber java -> what should be the main class?

The class is taken from the jar archive attached when enabling Cucumber support in project. By default, the main class name is cucumber.cli.Main:

Run/Debug Configuration: Cucumber Java

Do not forget to specify the package where your step definitions are stored in the Glue filed of the Cucumber Run/Debug Configuration.

Alfalfa answered 11/11, 2017 at 7:37 Comment(1)
cucumber.api.cli.Main is deprecated (6/2020) use io.cucumber.core.cli.Main instead.Sallyanne
S
1

I changed the Main class in the configuration to io.cucumber.core.cli.Main worked for me.

Shandeigh answered 9/6, 2020 at 9:58 Comment(2)
Hi, this post does not seem to provide a quality answer to the question. Please either edit your answer and improve it, or just post it as a comment to the question/other answer.Christabella
THis doesn't work for me . It says 'cucumber' not found in the Module/classpath. I tried all the modules in my project and none of them workGrolier
C
0

I was getting the same issue and following the same idea from the @soumya-jain answer's, the package to get Cli class is different if you are using Cucumber version 4.2.6.

This java doc (https://javadoc.io/doc/io.cucumber/cucumber-core/4.2.6/index.html) says the Cli class is located at "cucumber.api.cli.Main".

So, it depends on which Cucumber dependency you are using in your project.

Cheers!

Chet answered 24/7, 2020 at 12:37 Comment(0)
E
0

I encountered this issue in Eclipse when I ran my feature file. I have provided these versions for cucumber and Rest assured:

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>7.11.1</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>7.11.1</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>5.3.0</version>
    <scope>test</scope>
</dependency>

I downgraded the version of my cucumber related dependencies to 7.3.1. That solved the issue. May be there is some internal incompatibility. This is my experience with Eclipse. Posting it as reply to this issue in case it may be helpful.

Enfeeble answered 23/3, 2023 at 16:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.