I am trying to create a cucumber test for a REST endpoint in Java. The cucumber version I am using is: 3.0.2.
It is aa GET Request and takes 1 parameter that is of type, Long. I get the error:
Exception in thread "main" cucumber.runtime.CucumberException: Could not create a cucumber expression for 'parameter carrierTender {Long}'. It appears you did not register parameter type.
The Feature file is as follows:
Scenario Outline: Get the purchase tender data for a given carrier tender id
Given parameter carrierTender <carrier_tender_id>
When the Purchased Service requests purchase tender data
Then the result has a return Code <return_code>
And a purchase tender record is returned
Examples:
| carrier_tender_id | return_code |
| 12345678 | 200 |
The Step Definitions are as follows:
@Given( "parameter carrierTender {Long}")
public void parameterCarrierTenderCarrierTenderId(Long arg0) {
carrierTenderId = arg0;
}
@When("the Purchased Service requests purchase tender data")
public void purchasedServiceRequestsPurchaseTenderData() throws URISyntaxException, IOException {
// String purchaseTenderPathValue = "purchaseTender/" + Long.valueOf(carrierTenderId);
URIBuilder uriBuilder = new URIBuilder(getRequest.getURI() + "purchaseTender")
.setParameter("carrierTenderId", String.valueOf(carrierTenderId));
LOGGER.info("URL Request: {}", uriBuilder.getPath());
getRequest.setHeader("Accept", "application/json");
getRequest.setHeader("Content-type", "application/json");
getRequest.setURI(uriBuilder.build());
getResponse = httpClient.execute(getRequest);
LOGGER.info("Response: {}", getResponse.toString());
}
@Then("the result has a returnCode {int}")
public void onSuccessfulResultTheResultHasAReturnCode(int arg0) {
assertEquals(arg0, getResponse.getStatusLine().getStatusCode());
}
@And("a purchase tender record is returned")
public void purchaseTenderRecordReturned() {
assertNotNull(getResponse.getEntity());
}
Does Cucumber not recognize the Long Data type? In the cucumber documentation it says it does so I am not sure if it is the data type or something else.
这很愚蠢。。。我将数据类型从Long
更改为long
并被识别。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.