Search code examples
javagradlebuild.gradlegradlewkarate

How to run Karate Test on Gradle Using Command line


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


Solution

  • 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