@@ -451,22 +451,22 @@ If you have installed the bridge through Composer, you can run it by calling e.g
451
451
If you still need to use ``prophecy `` (but not ``symfony/yaml ``),
452
452
then set the ``SYMFONY_PHPUNIT_REMOVE `` env var to ``symfony/yaml ``.
453
453
454
-
455
454
Code coverage listener
456
455
----------------------
457
456
458
457
Use case
459
458
~~~~~~~~
460
459
461
- By default the code coverage is computed with the following rule: If a line of
462
- code is executed then it is marked as covered. And the test who executes a line
463
- of code is therefore marked as "covering the line of code".
460
+ By default the code coverage is computed with the following rule: if a line of
461
+ code is executed, then it is marked as covered. And the test which executes a
462
+ line of code is therefore marked as "covering the line of code". This can be
463
+ misleading.
464
464
465
- This can be misleading. Considering the following example::
465
+ Consider the following example::
466
466
467
467
class Bar
468
468
{
469
- public function barZ ()
469
+ public function barMethod ()
470
470
{
471
471
return 'bar';
472
472
}
@@ -481,9 +481,9 @@ This can be misleading. Considering the following example::
481
481
$this->bar = $bar;
482
482
}
483
483
484
- public function fooZ ()
484
+ public function fooMethod ()
485
485
{
486
- $this->bar->barZ ();
486
+ $this->bar->barMethod ();
487
487
488
488
return 'bar';
489
489
}
@@ -496,21 +496,20 @@ This can be misleading. Considering the following example::
496
496
$bar = new Bar();
497
497
$foo = new Foo($bar);
498
498
499
- $this->assertSame('bar', $foo->barZ ());
499
+ $this->assertSame('bar', $foo->fooMethod ());
500
500
}
501
501
}
502
502
503
503
504
- Here the ``FooTest::test `` will execute every lines of code so the code coverage
505
- will be 100%. But the ``Bar `` class is not tested.
506
-
507
- The ``CoverageListener `` aim to fix this behavior by adding the ``@covers ``
508
- annotation on the test class. If an annotation already exist then the listener
509
- do nothing.
510
-
511
- By default the listener try to find the tested class by removing the ``Test `` part
512
- of the classname: ``My\Namespace\Tests\FooTest `` -> ``My\Namespace\Foo ``.
504
+ The ``FooTest::test `` method executes every single line of code of both ``Foo ``
505
+ and ``Bar `` classes, but ``Bar `` is not truly tested. The ``CoverageListener ``
506
+ aims to fix this behavior by adding the appropriate ``@covers `` annotation on
507
+ each test class.
513
508
509
+ If a test class already defines the ``@covers `` annotation, this listener does
510
+ nothing. Otherwise, it tries to find the code related to the test by removing
511
+ the ``Test `` part of the classname: ``My\Namespace\Tests\FooTest `` ->
512
+ ``My\Namespace\Foo ``.
514
513
515
514
Installation
516
515
~~~~~~~~~~~~
@@ -531,7 +530,8 @@ Add the following configuration to the ``phpunit.xml.dist`` file
531
530
</listeners >
532
531
</phpunit >
533
532
534
- You can also configure a new System Under Test solver:
533
+ If the logic followed to find the related code is too simple or doesn't work for
534
+ your application, you can use your own SUT (System Under Test) solver:
535
535
536
536
.. code-block :: xml
537
537
@@ -543,10 +543,11 @@ You can also configure a new System Under Test solver:
543
543
</listener>
544
544
</listeners>
545
545
546
- The ``My\Namespace\SutSolver::solve `` should be a callable and will receive the
547
- current test classname as first argument.
546
+ The ``My\Namespace\SutSolver::solve `` can be any PHP callable and receives the
547
+ current test classname as its first argument.
548
548
549
- Finally the listener can add warning when the SUT solver does not find the SUT:
549
+ Finally, the listener can also display warning messages when the SUT solver does
550
+ not find the SUT:
550
551
551
552
.. code-block :: xml
552
553
0 commit comments