2

I have a Java Framework that contains some Cucumber Feature Files. It also contains some Karate Feature Files.

I have separate runners for each type of Feature File and both sets of tests run successfully.

However, when I view the Feature Files in Intellij...it always looks as though either the Cucumber or the Karate Step definitions cannot be found.

If I add ONLY a Karate dependency to the pom:

        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-junit5</artifactId>
            <version>1.1.0</version>
            <scope>test</scope>
        </dependency>

Then the karate steps in the Karate Feature Files are recognised but the Cucumber Steps in the Cucumber Feature Files are NOT recognised.

If I add ONLY a Cucumber dependency to the pom:

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>7.2.3</version>
        </dependency>

Then the Cucumber steps in the Cucumber Feature Files are recognised but the Karate Steps in the Karate Feature Files are NOT recognised.

Is there a way for BOTH to be recongnised at the same time?

I think it is a problem with the step definition location but I'm not sure how to overcome it.

Matt
  • 773
  • 2
  • 15
  • 30
  • this is beyond my expertise, the community is welcome to contribute. karate is NOT designed to play well with all cucumber versions, refer this for the gory details: https://github.com/karatelabs/karate/issues/444#issuecomment-419852761 – Peter Thomas Mar 08 '22 at 17:36
  • 2
    I believe you can specify where to look for the step definitions for the Cucumber side. I also remember IntelliJ not recognizing my Karate code correctly unless I specificied a `test` folder in the project settings. – anutter Mar 08 '22 at 18:51

1 Answers1

2

IDEA uses a simple heuristics to determine which Cucumber version to use. If the latest version is detected, that one is used.

However Karate depends on the older versions of Cucumber. So when using Karate and a recent version of Cucumber IDEA will ignore Karate.

To fix this properly Peter would have to provide his own step definition annotations. And then IDEA could use those next to the ones from Cucumber.

But that means waiting for Jetbrains which I imagine Peter is loath to do.

M.P. Korstanje
  • 10,426
  • 3
  • 36
  • 58
  • Since I've been mentioned in this comment, let me say this. 1) Karate is now more popular than Cucumber: https://twitter.com/ptrthomas/status/1424259563503587330 - teams should seriously consider dropping the pursuit of "BDD" and using the Karate approach of test-automation. 2) test-readability by business-users is over-rated: https://stackoverflow.com/a/47799207/143475 and 3) in the long term, Karate will have a dedicated IntelliJ IDEA plugin – Peter Thomas Mar 09 '22 at 04:13
  • 1
    You've been mentioned but you haven't commented on why Karate doesn't provide its own annotations. Can I from your lack of comment infer that you are indeed loathe to wait for Jetbrains to add dedicated support? – M.P. Korstanje Mar 09 '22 at 10:56
  • I thought I made this clear in my comment under the question - that we don't mind if Jetbrains or the community contributes anything missing, it is not a priority for the project - but you are most welcome to infer whatever you want. – Peter Thomas Mar 09 '22 at 13:41