I’m not seeing what Namely is - is that a function in your test or a built-in BDD syntax? When I try you example, Katalon gives me a “lexing error” - is that what you see? If so, here’s some info on what that error might mean:
Here’s an overview BDD in Katalon:
And here’s a sample repo with some code that might help:
I don’t think it’s a Lexington Error, I used Namely just as a typo for viz / such as. Here I am enclosing my feature file again along with groovy script it requires. See if it works with / without When Statement.
Feature: Calculating Couple Of Numbers.
Scenario Outline: ADD, DEVIDE, MULTIPLY, SUBTRACT
Given There Are Two Numbers
#When Namely <first_number> And <second_number>
Then Lets Print Requests Results
Examples:
| first_number | second_number | Result |
| 5 | 7 | success |
| 7 | 9 | Fail |
class calculatingNumbers {
/**
* The step definitions below match with Katalon sample Gherkin steps
*/
@Given("There Are Two Numbers")
def I_check_for_the_value_in_step() {
println ("Within Given");
//String addResponse = WS.sendRequest(findTestObject('Calculator API/Add Numbers'));
}
@Then("Lets Print Requests Results")
def printingResults() {
String addResponse = WS.sendRequest(findTestObject('Calculator API/Add Numbers'));
println (addResponse);
String devideResponse = WS.sendRequest(findTestObject('Calculator API/Devide Numbers'));
println (devideResponse);
String multiplyResponse = WS.sendRequest(findTestObject('Calculator API/Multiply Numbers'));
println (multiplyResponse);
String subtractResponse = WS.sendRequest(findTestObject('Calculator API/Subtract Numbers'));
println (subtractResponse);
}
@When("Namely (.*) And (.*)")
def chekingNumbers(int a, int b) {
println (a, b);
}
}
When you run this from test case using cucumber keywords for feature file or feature folder for example
The @When statement takes a regular expression or a Cucumber expression. In your case, you have it as a regular expression, reads .* as “any string of characters”. This means that those parameters are being parsed from your feature file as strings. That’s why you’re getting a type mismatch error when trying to use def checkingNumbers(int a, int b) - you’re actually passing in strings for a and b.
If you want it to parse the @When line parameters as integers, you can do it like this in a Cucumber expression: