Sami
Sami

Reputation: 305

Cucumber - what's the difference between these two givens?

New to this whole BDD world, and I'm already experiencing weird behavior.

So in the three "Given" statements below, they all refer to the ints in the table, right? So I thought when mapping (see second pic), I just replace all the "<...>" tags with "{int}", but that's not the case. , , , stay the same and are not replaced by {int}, but is replaced by {int}.

Is this normal? If so, what's the rule? enter image description here

enter image description here

Upvotes: 0

Views: 411

Answers (2)

Nilesh Pawar
Nilesh Pawar

Reputation: 26

Your step definition for gherkin steps Given An X .... and Given An O.... does not meet the required criteria to accept the int parameter. In step definition when a integer value is expected to be received as parameter you must use {int} or (\d+). Which means your step definition for first two given statement would be as follow

@Given("^An X is added at row {int}, {int}$")
@Given("^An O is added at row {int}, {int}$")

Upvotes: 0

Marit
Marit

Reputation: 3026

In your step definition, where you specify which text should be matched by your step, you need to specify which Cucumber expression should be matched.

Change the first two step definitions to: @Given("An X is added at row {int}, {int}) and @Given("An O is added at row {int}, {int})

(Sidenote on asking questions: next time please copy your feature file and code into your question. That makes it easier to answer using your snippets.)

Upvotes: 1

Related Questions