问题
Unable to execute karate scenario from intellij OS: Mac Intellij version: Karate scenario cannot be executed from intellij Karate version:
compile group: 'io.cucumber', name: 'cucumber-core', version: '4.7.0' testCompile group: 'junit', name: 'junit', version: '4.12' testCompile group: 'com.intuit.karate', name: 'karate-apache', version: '0.9.3' testCompile group: 'com.intuit.karate', name: 'karate-junit4', version: '0.9.3'
Error message
Error: Could not find or load main class cucumber.api.cli.Main
Caused by: java.lang.ClassNotFoundException: cucumber.api.cli.Main
回答1:
You are trying to mix Cucumber and Karate which is not supported. Refer to this issue for the gory details.
So try without the Cucumber dependency. For instructions on how to get started on IntelliJ - please refer this video: https://youtu.be/W-af7Cd8cMc
回答2:
The issue got resolved by setting the Switch IDE Boot JDK to default and deleting the cache and restart. The cause this was due to multiple jdk I have installed in my machine (JDK8 and JDK 12). Deleted the old one and set the boot JDK to 12.
The issue is not with Karate library, its with the IntelliJ configuration.
来源:https://stackoverflow.com/questions/57194777/karate-scenario-cannot-be-executed-from-intellij