2

I was having a looking on the Karate documentation : https://github.com/intuit/karate#command-line

And have my files as follow:

Runner class:

import org.junit.runner.RunWith;
import com.intuit.karate.junit4.Karate;
import cucumber.api.CucumberOptions;

@RunWith(Karate.class)
@CucumberOptions(features = "classpath:feature/country.feature")
public class APITest {}

Place this to my build.gradle:

test {
    // pull cucumber options into the cucumber jvm
    systemProperty "cucumber.options", System.properties.getProperty("cucumber.options")
    // pull karate options into the jvm
    systemProperty "karate.env", System.properties.getProperty("karate.env")
    // ensure tests are always run
    outputs.upToDateWhen { false }
}

And I'm trying to run gradle like this:

./gradlew test -Dtest=APITest

But I'm getting this response:

Rafaels-MacBook-Pro:TestProject rafaelpaz$ ./gradlew test -Dtest=APITest
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test

However, I can't see if my tests passed or not. What am I doing wrong?

Gradle version : 2.14.1

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Rafael Paz
  • 497
  • 7
  • 22
  • are you sure you have the syntax right to run a single test: https://stackoverflow.com/questions/22505533/how-to-run-only-one-test-class-on-gradle – Peter Thomas May 24 '18 at 05:36
  • @PeterThomas Thanks again to step up to help Peter, I tried those commands before and I was able to succeed, but only with JUnit, with Karate I get errors like this: `FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':test'. > No tests found for given includes: [org.gradle.APITest] * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.` It's something I'm doing wrong, but still didn't realised what – Rafael Paz May 24 '18 at 05:58
  • sorry I can't help. man please switch to maven. I'm again going to ask on twitter for help – Peter Thomas May 24 '18 at 06:24
  • 1
    @PeterThomas All good mate, thanks for the help anyway! I'll still run more tests! Cheers – Rafael Paz May 24 '18 at 06:28

1 Answers1

5

https://github.com/SreecharanShroff/demos/blob/master/gradle_karate_demo.zip has a working gradle karate demo project, please change .feature file according to your requirement. use:

gradle clean test

please let me know if you need more info

Thanks,

Sreecharan Shroff

  • 1
    That's what I really needed, Sreecharan! Thank you so much for the help! I accepted your answer! Cheers mate! – Rafael Paz May 24 '18 at 20:59
  • Hi @Sreecharan Shroff, my test run succeeded but I don't see the generated report HTML file when I use the gradle command line for running my test, Please help if you know about this. – Vijay Makwana Apr 25 '19 at 06:33
  • in gradle, by default reports are generated in projectFolder/build/reports. I tried with Karate 0.9.2, reports are generated properly. you can try my gradle karate project from above link. please attach your project to reproduce the issue. – Sreecharan Shroff Apr 27 '19 at 11:49