Comments (5)
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.
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.
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.
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.
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.
- 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
- 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)
- Handle XDebug 3 configuration better HOT 1
- Give suggestion for Xdebug 'coverage' not on HOT 1
- Possible to split branchAndPathCoverage HOT 2
- Optionally fail Behat run when coverage is below threshold HOT 2
- How to configure the extension when the test suite is in another directory ? HOT 2
- Has no coverage for application code HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from behat-code-coverage.