Open jdlabails opened 7 years ago
@jdlabails This is hard actually. You are expecting atoum, or xdebug, to guess the total code to cover, just run a part of it, and make the score relative to the total. The hard part is “guess the total”, which is… impossible actually.
I understand your issue, but… hmm… An alternative would be to load the entire code, and run just a part of it with test cases. In your situation, only the code being executed is loaded, so the total to cover is not the total of the code of your project.
Am I clear?
@jdlabails @Hywan actually, there is a workaround to do this. Let me find it.
@jdlabails something like this should do the trick:
// .atoum.php
$coverageField = new atoum\report\fields\runner\coverage\html(
'Code coverage',
$path = __DIR__.'/web/coverage'
);
$coverageField->setRootUrl('http://127.0.0.1:8084/coverage/index.html');
$coverageField->addSrcDirectory(
__DIR__ . '/src',
function($file) {
if($file->isDir()) {
return true;
}
if($file->getExtension() === 'php') {
return true;
}
return false;
}
);
Thanks for your responses. @jubianchi your trick doesn't seems to work :( I got the same result.
Some files, for example an entity, explicitly load into a test via a "new" do not appear in the code coverage. But this php part is obviously loaded during the test. Do you see a reason why ?
Thanks again
This is still failing in the latest version.
Call atoum cli running:
$ ./bin/atoum --no-code-coverage-in-directories vendor
Or adding to .atoum.php
:
$script->excludeDirectoriesFromCoverage([__DIR__.'/vendor']);
The coverage (both HTML and CLI) is showing the coverage for vendor files (in my case, symfony classes). How can I ignore these folders from the overall coverage?
Hello,
Maybe i'm wrong but it seams that Atoum code coverage works only on tested classes and not on the tested directory. For exemple, in a symfony project, I would like to know my test code coverage over the src directory. But atoum tell me 80% if I just test only one class at 80% without testing the most part of the project. The expected response would be about 10%...
How can i do that ? is it possible ?
Thank you
NB :
use mageekguy\atoum\writers\std;
// directory on which we look for code coverage $runner->addTestsFromDirectory(DIR.'/src/');
$coverage = new atoum\report\fields\runner\coverage\html( 'Code coverage', $path = DIR.'/web/coverage' ); $coverage->setRootUrl('http://127.0.0.1:8084/coverage/index.html');
$images = DIR.'/vendor/atoum/atoum/resources/images/logo'; $notifier = new \mageekguy\atoum\report\fields\runner\result\notifier\image\libnotify(); $notifier ->setSuccessImage($images . DIRECTORY_SEPARATOR . 'success.png') ->setFailureImage($images . DIRECTORY_SEPARATOR . 'failure.png') ;
$script->excludeDirectoriesFromCoverage([DIR.'/vendor']);
$report = $script->AddDefaultReport(); $report ->addField($coverage, array(atoum\runner::runStop)) ->addField($notifier, array(atoum\runner::runStop)) ;