If we have set of scenarios and all the steps are same as each other apart from a few different sections then we can use scenario outlines to prevent duplications.


Controller


/**
* @Route("user")
*/
class UserController extends Controller
{
/**
* @param string $code
*
* @Route("/{code}", requirements={"code"="[A-Z]{2}"})
* @Method({"GET"})
*
* @return Response
*/
public function listAction($code)
{
$countries = [
'GB' => 'Great Britain',
'DE' => 'Germany',
'TR' => 'Turkey'
];

return new Response($countries[$code]);
}
}

Scenario


Feature: Just a test

Scenario Outline: I can get the country name by providing its code
Given I am on "/user/<code>"
Then the response status code should be 200
And the response should contain "<name>"

Examples:
| code | name |
| GB | Great Britain |
| DE | Germany |
| TR | Turkey |

Result


Inanzzz-MBP:football inanzzz$ bin/behat --profile=backend
Feature: Just a test

Scenario Outline: I can get the country name by providing its code
Given I am on "/user/<code>"
Then the response status code should be 200
And the response should contain "<name>"

Examples:
| code | name |
| GB | Great Britain |
| DE | Germany |
| TR | Turkey |

3 scenarios (3 passed)
9 steps (9 passed)
0m5.549s
Inanzzz-MBP:football inanzzz$