In karate While trying to define a variable getting "no step-definition method match found for: def referenceId= response.referenceId"
Asked Answered
D

2

5

On trying to store a value from response in a variable ,to use it for the next post call and facing "no step-definition method match found for: def referenceId= response.referenceId" this error.

Feature: To test GET /leads/{id} API

# To generate test data for getLeads 
Scenario: Test with valid flow
Given url baseUrl+leads
And request {some valid request body}
When method post
Then status 200
* assert response.referenceId != null
* def referenceId= response.referenceId


Scenario: Test with get call
Given url baseUrl+getLeadsByID+referenceId
When method get
Then status 200

Till the assert step working fine. While trying to set referenceId getting this ."no step-definition method match found for: def referenceId= response.referenceId"

Donetsk answered 5/7, 2019 at 15:2 Comment(0)
R
5

Please keep white space around the = sign:

* def referenceId = response.referenceId

If you use the Eclipse or IntelliJ Cucumber IDE support - it will help avoid this.

Ruble answered 5/7, 2019 at 15:44 Comment(0)
L
1

You have to have EXACTLY one whitespace on each side. [Accidental] double/multiple whitespaces, like

* def referenceId  =  response.referenceId

won't work either.

Lentha answered 30/12, 2020 at 8:48 Comment(1)
this should no longer be an issue in 1.2.0 onwardsRuble

© 2022 - 2024 — McMap. All rights reserved.