Git Product home page Git Product logo

Comments (5)

b2p-fred avatar b2p-fred commented on May 27, 2024 1

For sure it helps ! Many thanks for this very clear answer. I understand my problem and I will have a look at both of your suggestions. Once again, thanks.

from behat-code-coverage.

b2p-fred avatar b2p-fred commented on May 27, 2024

I suppose this may help ... some more information about my test environment:

  • symfony 6.0
  • api-platform 2.6
  • behat 3.10
  • behat-code-coverage: 5.2.2
  • phpunit/php-code-coverage: 9.2.10
  • phpunit/phpunit: 9.5

from behat-code-coverage.

dvdoug avatar dvdoug commented on May 27, 2024

Hello

How are you executing your tests - is it all in-process with the test framework invoking the controller with the relevant parameters, or are your tests making real HTTP calls into another process? It sounds like it might be the second one?

from behat-code-coverage.

b2p-fred avatar b2p-fred commented on May 27, 2024

Hello
yes it is the second one. I a m starting the Symfony development server which is listening on an HTTP port and I am starting behat in another process.

from behat-code-coverage.

dvdoug avatar dvdoug commented on May 27, 2024

The problem you're having is that it's not just enough to have the coverage driver installed, it has to actively be enabled to collect the coverage. This can only be done at runtime.

However, because your test suite and your code are running in separate processes, enabling it during test suite execution (which is what this library does), can only enable it for the code that is running inside Behat, it does not/cannot capture the code that's running inside the other process on the other end of the HTTP call. The coverage data you are seeing is probably just the code that is setting up fixtures etc

You've probably got 2 options.

  1. Switch (most?) of the tests to use a simulated HTTP call rather than an actual one. I'm not familiar with API Platform, but I know Symfony itself can do this, e.g. https://symfony.com/doc/current/testing.html#making-requests
  2. There is an alternative Behat coverage extension that you might want to look at: https://packagist.org/packages/matthiasnoback/behat-remote-code-coverage-extension that does allow for collecting coverage data from a different process, although setting it up is more complex.

Hope that helps

from behat-code-coverage.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.