What are Lexing's mistakes in cucumbers?
I tried to run a simple function file, but I was getting an exception: Exception on thread "main" cucumber.runtime.CucumberException: parse description file.
which is called: gherkin.lexer.LexingError: Lexing error
I am trying to parameterize a When statement and got this exception:
Scenario: Login to Gmail
Given User is on Gmail login page
When User enters <userName> and <pwd>
And Clicks on login button
Then User should redirect to home page
scenario outline(tried Examples as well but didn't worked):
|userName | pwd |
|ravivani10 | abc |
source to share
The correct syntax for a script outline is to start with the Script structure: keyword and list examples using the Examples: keyword .
Scenario Outline: Login to Gmail
Given User is on Gmail login page
When User enters <userName> and <pwd>
And Clicks on login button
Then User should redirect to home page
Examples:
| userName | pwd |
| ravivani10 | abc |
source to share
I had the same problem, but I was using the correct syntax. It turns out my formatting was wrong, yes you read it right: formatting. My script looked like this:
Scenario Outline: Confirm that hitting the endpoint returns the expected data
Given uri url/to/a/service/to/test/param/{interval} and method GET
And system user
When I call the web service
Then I expect that 'http status is' '200'
And the following rules must apply to the response
| element | expectation | value |
| $ | is not null | |
| objectType | value = | Volume |
| objectData | is not null | |
| objectData | count = | 1 |
| objectData[0].value | is not null | |
| objectData[0].value | data type is | float |
| objectData[0].value | value = | <value> |
Examples:
| interval | value |
| int1 | 355.77 |
| int2 | 332.995 |
| int3 | 353.71125 |
The above test will fail with Lexing error. Now take a look at the indentation in my example test (it's one level down in the Ouline script).
If I backtrack my test like this (same level as the script outline):
Scenario Outline: Confirm that hitting the endpoint returns the expected data
Given uri url/to/a/service/to/test/param/{interval} and method GET
And system user
When I call the web service
Then I expect that 'http status is' '200'
And the following rules must apply to the response
| element | expectation | value |
| $ | is not null | |
| objectType | value = | Volume |
| objectData | is not null | |
| objectData | count = | 1 |
| objectData[0].value | is not null | |
| objectData[0].value | data type is | float |
| objectData[0].value | value = | <value> |
Examples:
| interval | value |
| int1 | 355.77 |
| int2 | 332.995 |
| int3 | 353.71125 |
The above test will pass. Completely dumb to me, but that's how it works.
source to share
A lexing error from cucumber means the function file was not in the format that cucumber expects. This could be things like a script title with no content, or with a "Feature: blah" title twice. This will happen even if the error is not in the scenario in which you are working.
A vocabulary error usually gives you a line number. Can you post the message he is complaining about?
source to share
I got the same error and it was caused by the space between the word "Outline" and the colon character
Scenario Outline : Convert currencies
When I removed the space, I had this:
Scenario Outline: Convert currencies
..and the problem was resolved.
To identify the abuser, check your error logs and you will see on the line the line number where the error is located. I hope this helps someone
source to share
You need to do a couple of things: A) remove spaces in Feature: and Scripts: keywords; and B) change the script schema to script (or add missing schema examples).
If you run this function:
Feature: proof of concept that my framework is working
Scenario: my first test Considering this is my first test When this is my second step Then this is the last step Then cucumber will output the step definitions to complete:
You can implement step definitions for undefined steps with the following snippets:
Given (/ ^ this is my first test $ /) do pending # Write code here that turns the phrase above into concrete actions end
When (/ ^ This is my second step $ /) do pending # Write code here that turns the phrase above into concrete actions end
Then (/ ^ This is the last step $ /) do pending # Write code here that turns the phrase above into concrete actions end
source to share