Kalpesh Soni
Kalpesh Soni

Reputation: 7257

Springboot test with coverage in Intellij

I have a spring boot 2 project with maven pom in Intellij

I thought maven uses different internal coverage tools compared to jacoco or something similar

If I click on - Run All Feature in Test with coverage

I get

Error: Could not find or load main class cucumber.api.cli.Main

If I add cucumber dependency (I dont have cucumber based tests or want it)

Exception in thread "main" cucumber.runtime.CucumberException:
No backends were found. Please make sure you have a 
backend module on your CLASSPATH.

I just want to run simple spring boot rest based tests with coverage

What setup do I need?

Edit:

I had

Caused by: java.lang.ClassNotFoundException: org.jetbrains.plugins.cucumber.java.run.CucumberJvm3SMFormatter

I needed this in the pom

<dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>1.2.2</version>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.2.2</version>
    </dependency>

and needed cucumber for java plugin installed

Now everything runs, no errors

BUT no code coverage, it is blank

Upvotes: 1

Views: 3720

Answers (2)

y.bedrov
y.bedrov

Reputation: 6024

It's a known issue that JUnit is not suggested from context menu of project root: https://youtrack.jetbrains.com/issue/IDEA-198762

Upvotes: 2

M.P. Korstanje
M.P. Korstanje

Reputation: 12019

It appears you have the Cucumber integration installed in IDEA. This adds the option to run all feature files in the root of your project. If you want to run JUnit tests you have to drill down to src/main/test/java and select "Run All Tests".

Upvotes: 1

Related Questions