Search code examples
apitestingeclipse-plugincucumber-jvmkarate

Not able to run the feature files written in karate as a cucumber feature in eclipse


I have my cucumber eclipse plug in installed. I have written my simple feature file in karate and when I was trying to run this as a cucumber test, I have been asked to implement the missing steps. When I run the same feature file with a dedicated runner, it executes without any issues. Request you to please help on this. I am trying to get this test run without the use of a dedicated runner

Scenario: Validate that the sample webservice is up and running
Given url sampleUrl
When method get
Then status 200

Scenario: Validate a Json key value pair from the received response
Given url sampleUrl
When method get
Then status 200
And match $.RestResponse.result contains {name: 'United States of America', alpha2_code: 'US', alpha3_code: 'USA' }

*** Console output
Feature: Test a sample RESTFUL webservice
15:05:10.725 INFO  - Starting scenario: Validate that the sample webservice is up and running
15:05:10.725 INFO  - Ending scenario: Validate that the sample webservice is up and running
15:05:10.741 INFO  - Starting scenario: Validate a Json key value pair from the received response

  #Test Scenarios
  Scenario: Validate that the sample webservice is up and running # C:/Users/sxs8680/git/BDDCucumberJVM/src/test/java/com/thd/common/karatesupport/karatesample.feature:6
    Given url sampleUrl
    When method get
    Then status 200
15:05:10.741 INFO  - Ending scenario: Validate a Json key value pair from the received response

  Scenario: Validate a Json key value pair from the received response                                                   # C:/Users/sxs8680/git/BDDCucumberJVM/src/test/java/com/thd/common/karatesupport/karatesample.feature:11
    Given url sampleUrl
    When method get
    Then status 200
    And match $.RestResponse.result contains {name: 'United States of America', alpha2_code: 'US', alpha3_code: 'USA' }

2 Scenarios (2 undefined)
7 Steps (7 undefined)
0m0.006s


You can implement missing steps with the snippets below:

Given("^url sampleUrl$", () -> {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
});

When("^method get$", () -> {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
});

Then("^status (\\d+)$", (Integer arg1) -> {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
});

Then("^match \\$\\.RestResponse\\.result contains {name: 'United States of America', alpha(\\d+)_code: 'US', alpha(\\d+)_code: 'USA' }$", (Integer arg1, Integer arg2) -> {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
});

Solution

  • You may have the wrong Cucumber Eclipse plugin or you need to do some minor configuration.

    Please refer to this section of the documentation: Troubleshooting Cucumber IDE support