Mock Symfony service in Behat functional test

  behat, mocking, symfony, testing

What is the best and correct way to mock a Symfony Service using Behat and kerneldriver suite?

I have a Service that performs external API calls and I need to mock it to improve test performances and to get fake data to drive my tests.

I know I cannot replace a container service at runtime because the container is compiled, and I do not want to change the Service class for test environment because the mocked service should return different data in each scenario.

Any advice would be really appreciated, thank you.

Source: Symfony Questions