-1

**Can such implementation be done in Karate (this did not work locally for me) ?: ** public class CreateRetrieveUpdateDelete { StepDefs stepDefs = new StepDefs();

@When("^Create using service ([^\\\"]*)$")
public void whenCreate(String service, String payload) {
    stepDefs.url(service);
    stepDefs.request(payload);
    stepDefs.method("post");
    stepDefs.matchContains("", "", "", "", "", "");
    stepDefs.status(201);
}

@When("^Retrieve using service ([^\\\"]*)$")
public void whenRetrieve(String service) {
    stepDefs.url(service);
    stepDefs.method("get");
    stepDefs.matchContains("", "", "", "", "", "");
    stepDefs.status(200);
}

@When("^Update using service ([^\\\"]*)$")
public void whenUpdate(String service, String payload) {
    stepDefs.url(service);
    stepDefs.request(payload);
    stepDefs.method("put");
    stepDefs.matchContains("", "", "", "", "", "");
    stepDefs.status(201);
}

@When("^Delete using service ([^\\\"]*)$")
public void whenDelete(String service) {
    stepDefs.url(service);
    stepDefs.method("delete");
    stepDefs.status(204);
}

}

  • I edited the question and tag because this is not a Karate question. – Peter Thomas Mar 24 '18 at 08:52
  • @PeterThomas works fine with OOTB cucumber-jvm-maven project, after integrating Karate into the same project, only Karate step fails. uploading the OOTB project in github at: https://github.com/SreeCharanShroff/cucumberjvm_demo_karate/blob/master/cucujvmdemo.zip – Sreecharan Shroff Mar 24 '18 at 10:29
  • your question is wrong. it should be “can i use cucumber concepts with karate” - and the answer is no. however many times you ask :P – Peter Thomas Mar 24 '18 at 10:57

2 Answers2

0

Karate is not designed to be mixed with Cucumber.

See this Stack Overflow answer: https://stackoverflow.com/a/46229979/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
-1

finally something worked like composite steps which reduces lots of boilerplate steps in feature file while using Karate, I added this method in StepDefs.java, did mvn clean install, then added a Scenario in .feature, can we have such composite steps readily baked into Karate ?

@When("I Retrieve using service (.+)$")
public void whenRetrieve(String service) {
    request.setUrl("http://localhost:3000/" + service);
    method("get");
    String responseBody = response.toString();
    System.out.println(responseBody);
    status(200);
}

Feature:
CRUD demo

Background:
Demo CRUD

Scenario: Retrieve
When I Retrieve using service posts/1/
  • since you claim it is working why are you asking me the question ? go and create your own framework and leave everybody else in peace. and for the record, the answer to your question is *NO*. – Peter Thomas Mar 26 '18 at 02:50
  • https://www.youtube.com/edit?o=U&video_id=neOZEWhgZmk video on how to integrate Maven, JBehave, Karate with Method Composition – Sreecharan Shroff Apr 16 '18 at 17:28
  • well done. I can't see the video since you have linked to your own playlist or something. I'm working on more important things like integrating gatling with karate. all the best :P – Peter Thomas Apr 16 '18 at 17:40
  • not sure if this will convince Mr. SreeCharan Shroff, but I'm posting this link for the benefit of others who may want to understand why karate's syntax is designed the way it is: https://stackoverflow.com/a/47799207/143475 – Peter Thomas Apr 16 '18 at 17:52