Follow the steps below to see how the code coverage feature works in NetBeans:
1. Open
Calculator.php
, add a duplicateadd
function, and name itadd2
. TheCalculator
class now looks similar to the following:<?php class Calculator { /** * @assert (0, 0) == 0 * @assert (0, 1) == 1 * @assert (1, 0) == 1 * @assert (1, 1) == 2 * @assert (1, 2) == 4 */ public function add($a, $b) { return $a + $b; } public function add2($a, $b) { return $a + $b; } } ?>
2. Right-click on the project node. From the Context menu, select Code Coverage | Collect and Display Code Coverage. By default, the Show Editor Bar is also selected.
3. The editor now has a code coverage editor bar across the bottom. Since code coverage has not been tested, the editor bar reports
0.0%
coverage (it also displays such a percentage after you click on Clear to clear the test results).4. Click on Test to test the opened file or All Tests to run all the tests for the project. The test...