Specifying coverage scope?
I have two Phpstorm projects. One is over ten times larger than the other. Both have 100% code coverage via PhpUnit tests.
The larger project performs code coverage very quickly. (A few seconds.)
The smaller project takes much, much longer. (On the order of 30 seconds.)
The only difference I can see is that after running coverage, the larger project only reports coverage for the project's src directory. There's nothing listed for any other directory. The smaller project shows 100% coverage for src but has 0% next to every other directory: example, tests, and (notably) vendor.
I'm pretty sure the smaller project is slow because it's trying to generate coverage for everything in vendor. Which is not useful.
As far as I know, I configured these projects the same way. And I generally use the IDE setting, not per-project settings. The only code coverage options I can find are the “ask about/add to/replace existing coverage" options. So I'm baffled.
Where do I configure this?
Thanks!
请先登录再写评论。
Solving my own problem here.
I eventually figured out that this happens if no directories are marked as “Sources Root.” If that's the case, it seems to treat the top-level project directory that way, thus including tests, vendor, etc.
Once I marked “src” as “Sources Root” the problem went away. It started correctly tracking coverage only for that directory and running very quickly as a result.
I suspect whether or not it's marked that way automatically is down to how I create the project (from scratch or from an existing directory).
Hope this helps someone else someday!