Requirements:
- Netbeans with PHPUnit(6.9)
- EDIT: Same applies, for example, to PHPStorm
How to:
- Exclude lines from code coverage.
- Exclude code blocks (lines) from code coverage.
Requirements:
How to:
If you are trying to achieve 100% code coverage but have one or more lines that you cannot test, you can surround them with special annotations. They will be ignored in the code coverage report.
if (($result = file_get_contents($url)) === false) {
// @codeCoverageIgnoreStart
$this->handleError($url);
// @codeCoverageIgnoreEnd
}
Edit: I have found that Xdebug often considers the closing brace to be executable. :( If that happens, move the end tag below it.
To ignore method code blocks:
/**
* @codeCoverageIgnore
*/
function functionToBeIgnored() {
// function implementation
}
To ignore class code blocks:
/**
* @codeCoverageIgnore
*/
class Foo {
// class implementation
}
And as @david-harkness said, to ignore individual lines:
// @codeCoverageIgnoreStart
print this line ignored for code coverage ;
// @codeCoverageIgnoreEnd
More information can by found in the PHPUnit Documentation under the Ignoring code blocks heading.
First make sure you have the latest and greatest phpunit or else the code ignore might be missing. Next create a phpunit.xml
file that looks something like this:
<phpunit colors="true">
<filter>
<blacklist>
<file>file1.php</file>
<file>file2.php</file>
</blacklist>
</filter>
</phpunit>
I m using Netbeans to develop with Drupal. I m trying to let Netbeans get drupal core and modules from the repository on drupal.org to my local working copy. Problem is: I already have a working ...
I have a Java web app using JDBC created in NetBeans deployed to Tomcat that gives a "java.sql.SQLException: No suitable driver found for ..." error. The same app works fine when I run it as a non-web ...
Does anyone know how to work with the Card Layout in the NetBeans GUI builder tool? I want to show panels as per the JRadioButton selection, so I want to lay this out using the Card Layout.
Quick personal background: I was hired a few months ago as the sole .NET developer (C#) by a company whose other devs are all php devs. A week into the job I was told they wanted to switch to Java ...
I m writing a Java ME app that will use privileged operations such as messaging. By default the user is prompted to confirm each of these operations, but I would like to run it as a background ...
Is there a way, a method, to be able to effectively run unit tests (phpunit) on both linux and windows? I need to do this because some parts of the system is only available under linux, but i do want ...
I m developing various in-house extensions for JIRA, the issue tracker we use. So far I worked with Netbeans and everything worked like a charm. However, now I need to switch to Eclipse and I m ...
I ve recently started using netbeans for a few hobby projects. I ve come from a JDeveloper background and I m used to been able to see my ant build file from the project explorer window. In ...