[SOLVED] How to resolve JSON Schema validation Error in Rest Assured – io.cucumber.core.exception.CucumberException: Could not convert arguments


This Content is from Stack Overflow. Question asked by Wilson

I was trying to do the JSON schema validation in Rest Assured using the below code by reading the filename loginschema.json from src/test/resources/data folder and was getting CucumberException. Can someone provide their inputs on how to resolve this issue?


public void verifyResponseBody(File fileName)  {
String pathName = "src/test/resources/data/"+ fileName +".json";

**Cucumber file:**
And I see response matches for fields
  | success | true |
Then I see response matches file loginschema

**Common Stepdefintion File:**

@Then("I see response matches file {}")
public void i_see_response_matches_file(File fileName) {

And I see response matches file loginschema                      # 
  io.cucumber.core.exception.CucumberException: Could not convert arguments for step [I see response matches file {}] defined at 'test.java.com.stepdefinitions.Common_StepDefintions.i_see_response_matches_file(java.io.File)'.


You get this error because you cannot just take an arbitrary sequence of chars from your steps (like you do with {}) and treat it as a File (argument type that your step takes).

You should change this public void i_see_response_matches_file(File fileName) to this public void i_see_response_matches_file(String fileName) and create File instance from that path internally within a step.

P.S. – Or you can create custom parameter type and describer conversion there.

This Question was asked in StackOverflow by Wilson and Answered by Alexey R. It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?