Get "Run Focused Test Method" to work in netbeans

952 Views Asked by At

A file, SearchTest.php, has:

public function testSearchThenBooking(){
...
}

When I right-click I can see "Run Focused Test Method" (and "Debug Focused Test Method"), but they are greyed out.

I realized the phpunit netbeans plugin was not installed. So I've installed that, restarted netbeans, but no difference.

phpunit from the commandline is working fine, and running and passing this function.

This answer show it is obviously working for some people! https://stackoverflow.com/a/30568731/841830

Do I need to configure my project to use phpunit, or tell it where phpunit is, or ... ?

1

There are 1 best solutions below

1
On

Yes, you need to manually download PHPUnit Script and Skeleton Generator Script

wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit

wget https://phar.phpunit.de/phpunit-skelgen.phar
chmod +x phpunit-skelgen.phar
sudo mv phpunit-skelgen.phar /usr/local/bin/phpunit-skelgen

and complete the Tools/Options/Frameworks & Tools form

enter image description here

Full details for installation and configuration can be found here. But even if you do that, it won't work because there is a bug in the last version of netbeans (8.0.2).

Bug 254276 - NetBeans v8.0.2 incompatible w/ latest PHPUnit version.

So you have two choices: either you use a nightly build that will contain the following patch solving the problem:

 1.1 --- a/php.phpunit/src/org/netbeans/modules/php/phpunit/commands/PhpUnit.java
 1.2 +++ b/php.phpunit/src/org/netbeans/modules/php/phpunit/commands/PhpUnit.java
 1.3 @@ -123,6 +123,7 @@
 1.4      private static final String COVERAGE_LOG_PARAM = "--coverage-clover"; // NOI18N
 1.5      private static final String LIST_GROUPS_PARAM = "--list-groups"; // NOI18N
 1.6      private static final String GROUP_PARAM = "--group"; // NOI18N
 1.7 +    private static final String PARAM_SEPARATOR = "--"; // NOI18N
 1.8      // bootstrap & config
 1.9      private static final String BOOTSTRAP_PARAM = "--bootstrap"; // NOI18N
1.10      private static final String BOOTSTRAP_FILENAME = "bootstrap%s.php"; // NOI18N
1.11 @@ -319,6 +320,8 @@
1.12              // #218607 - hotfix
1.13              //params.add(SUITE_NAME)
1.14              params.add(getNbSuite().getAbsolutePath());
1.15 +            // #254276
1.16 +            params.add(PARAM_SEPARATOR);
1.17              params.add(String.format(SUITE_RUN, joinPaths(runInfo.getStartFiles(), SUITE_PATH_DELIMITER)));
1.18          }
1.19  

either you wait for the next release.