X

An Oracle blog about NetBeans for PHP

UI for PHPUnit support

Guest Author

I would like to continue writing about our PHPUnit support in NetBeans; today, let's have a look at our new addition - UI for test results.

First of all, please be sure that you have PHPUnit 3.3.0 or newer installed, otherwise you won't be able to use this new UI for test results (most features will be still available - Create PHPUnit test, Run/Debug file with results in Output window only).

Before we move on, let me thank Erno Mononen for his great job; Erno takes care about the common part of UI test runner for all the scripting languages in NetBeans (namely Ruby, Python, PHP). Visit his blog to get more information, you will see that some features are still missing in PHP, most of them because of lack of time, some of them are waiting for the upcoming release PHPUnit 3.4.0.

Now, let's move finally to the UI, let's test our PHP project:

Test a PHP project

When the results are ready, UI appears:

UI for PHPUnit's test results

As you can see, if some of our tests failed, one can easily investigate problems via messages attached directly to failing tests or using Output window. All this information is available as a tooltip as well (applies for test suite as well as for each test case).

Tooltip for failed tests

Similar UI is displayed when user tests just one file (via Run file action, shortcut SHIFT + F6).

Results for one test case

One can use buttons on the left side to rerun tests Rerun tests, to show only failed or all tests Show failed/all tests or to navigate to the previous or next failed test Go to next/previous failed test.

The whole output of PHPUnit script is available in Output window and could be very useful if, for example, any error occurs.

Text output of PHPUnit

As always, this feature is available in development version of NetBeans, please feel free to file issues in NetBeans IssueZilla (component php, subcomponent phpunit).

That's all for today, thanks for reading and we hope you enjoy this great new feature of PHP support in NetBeans!


Join the discussion

Comments ( 53 )
  • raymond Monday, February 2, 2009

    Hi Tomas,

    This looks great!

    How about bundling NetBeans with PHPUnit and XDebug so we developers don't have to go through the task of setting up these environments.


  • Rob Weaver Monday, February 2, 2009

    Nice, now all I need is for Cake (http://cakephp.org) and Maven for PHP (http://www.php-maven.org/) to be added and PHP will be cooking with propane.


  • Tomas Mysik Monday, February 2, 2009

    To raymond: Bundling of PHP libraries is always problematic - one would like to use another version, the download size of the IDE grows and grows, PHP Include path has to be set correctly (so php.ini must be known and writable) etc.

    With XDebug it's even more complicated - it's PHP extension so you have to solve issues with different PHP versions, operating systems etc.

    Thanks for your positive feedback!

    Tomas


  • Tomas Mysik Monday, February 2, 2009

    To Rob Weaver: To CakePHP - what kind of support exactly would you like to have in NetBeans? Could you please update issue http://www.netbeans.org/issues/show_bug.cgi?id=140918 if needed?

    Could you please file a new issue for Maven for PHP?

    Thanks,

    Tomas


  • Michal Tuesday, February 3, 2009

    Hello,

    I'm watching netbeans php cvs mailing list to see what new cool features are you doing ;)

    You were rewriting PHP parser recently? For some new netbeans parser framework?

    Could you write something about it?


  • Tomas Mysik Tuesday, February 3, 2009

    To Michal:

    Nice to read, thanks a lot! :) Anyway, not sure which parser you mean exactly; the only parser I wrote last time is the one which parses XML log files produced by PHPUnit (to visualize test results, described in this blog post). But stay tuned, I hope I will finish soon another interesting parser; I will blog about it, of course (if I'm successful).

    Thanks for positive feedback.


  • Michal Tuesday, February 3, 2009

    Hello,

    I'm talking about commit messages like "[hg] jet-parsing-api/php.project: GSF->CSL Migration, phase 0"

    I thought it's related with this http://wiki.netbeans.org/ParsingAPI


  • Tomas Mysik Wednesday, February 4, 2009

    To Michal:

    Ah, I see now; yes, it's related to new infrastructure for editors but I don't know much about this area, editor guys do.


  • Michal Kocian Thursday, February 5, 2009

    Hi,

    I have an issue with test creating:

    Reproduce code:

    <?php

    class Foo extends Bar {

    public function neco(){}

    }

    ?>

    Tools -> Create PHPUnit tests

    Result: Warrning

    Test were not generated for the following files:

    foo.php

    In output:

    Fatal error: Class 'Bar' not found in /var/www/ .... /models/foo.php on line 2

    (in application class 'Bar' is loaded by autoloading)


  • Tomas Mysik Thursday, February 5, 2009

    To Michal:

    Please, file all the issues directly to IssueZilla and not here. Thanks a lot.

    (However, looks like a bug in PHPUnit?)


  • Michal Kocian Thursday, February 5, 2009

    Tomas:

    I have no idea, I am new in PHPUnit testing.

    http://www.netbeans.org/issues/show_bug.cgi?id=157983


  • Gustavo Schirmer Sunday, February 8, 2009

    Hey Tomas,

    Its a little late now... and im such tired, i cant really think in a good way to say:

    Congratulations!

    Wonderful job with Netbeans! Its primary IDE for PHP work!!

    U got a devoted follower!

    Btw,


  • Michal Tuesday, February 10, 2009

    Hello,

    This is offtopic, but maybe you will how it's going with development of subversion support in netbeans. Is it actively developed? Are there any blog, mailing list which describes fixes and new features?


  • Tomas Mysik Wednesday, February 11, 2009

    To Gustavo Schirmer:

    Thanks a lot! Nice to hear, really!


  • Tomas Mysik Wednesday, February 11, 2009

    To Michal:

    Some information for subversion support in NetBeans IDE can be found here:

    http://subversion.netbeans.org/

    Please, report all issues using NB IssueZilla, component "subversion". Thanks.


  • Warhammer Online Gold Wednesday, March 11, 2009

    To raymond: Bundling of PHP libraries is always problematic - one would like to use another version, the download size of the IDE grows and grows, PHP Include path has to be set correctly (so php.ini must be known and writable) etc.

    With XDebug it's even more complicated - it's PHP extension so you have to solve issues with different PHP versions, operating systems etc.

    Thanks for your positive feedback!

    Tomas


  • alexey_baranov Friday, April 24, 2009

    Hello!

    How about a dynamic synchronization of classes and tests? That is, if I do the test first time, then get it all the methods of the class. Similarly, I would like to be able to add a new method in the class and select "Add method to Class's TestCase". Is it possible in the future?


  • alexey_baranov Friday, April 24, 2009

    Is it possible to do transitions between the model, view and controler like you did between a class and its test (in the menu "Navigate/Go to test- Navigate/Go to tested class" and shortcut "Alt + Shift + T"). It is constantly required to do as with tests.

    To determine the classes of triples can be used files names and the names of the classes.

    for example,

    model: class ModelName in file ModelName.php

    view: class ModelNameView in file ModelNameView.php

    controller: class ModelNameControler in file ModelNameControler.php

    Thanks!


  • guest Friday, April 24, 2009

    > Congratulations!

    > Wonderful job with Netbeans! Its primary IDE for > PHP work!!

    Absolutely agree. Great work!


  • alexey_baranov Friday, April 24, 2009

    > Congratulations!

    > Wonderful job with Netbeans! Its primary IDE for > PHP work!!

    Absolutely agree. Great work!


  • Tobias Monday, May 11, 2009

    How does Netbeans check which version of PHPUnit is installed?

    I am running the latest version (installed via PEAR), but I always get:

    PHPUnit (version ?.?.?) is too old, upgrade it if possible (the minimum version is 3.3.0).

    Creating and running individual test is still possible.

    What can I do to resolve this problem?


  • Tobias Monday, May 11, 2009

    Ok, I found it out myself:

    Go to file "[..]/pear/PEAR/PHPUnit/Runner/Version.php".

    Replace

    "return 'PHPUnit 3.4.0beta3 by Sebastian Bergmann.';"

    with

    "return 'PHPUnit 3.4.0 by Sebastian Bergmann.';"

    I wonder why Netbeans does not make use of the function "public static function id()" which returns only the version.


  • system Monday, July 6, 2009

    Thanks a lot! Nice to hear, really!


  • yat kiralama Monday, July 6, 2009

    teşekkürler benim sitemde http://www.yatkiralamafiyatlari.com


  • serg Friday, July 17, 2009

    After changing source file (eg arguments for asserts) and creating new test (Tools->Create PHPUnit test) it should ovewrite old test file.

    Now we must delete test file.


  • istanbul transfer Friday, July 17, 2009

    istanbulda transfer de bir numarayız :)


  • istanbul transfer Friday, July 17, 2009

    gercekden :)


  • istanbul transfer Friday, July 17, 2009

    özel taşımacılık


  • Point of Sale Sunday, July 19, 2009

    Pretty cool set of resources...thanks

    http://winshow09.spaces.live.com


  • mak Thursday, August 20, 2009

    i have same problem as tobias, that is this error "PHPUnit (version ?.?.?) is too old, upgrade it if possible (the minimum version is 3.3.0).", the fix suggested by tobias doesn't work, the version given in Runner.php file is 3.3.17

    hope someone can help me resolve this


  • g&ouml;&#287;&uuml;s esteti&#287;i Thursday, August 20, 2009

    Reproduce code:

    <?php

    class Foo extends Bar {

    public function neco(){}

    }

    ?>


  • mirc Saturday, August 22, 2009

    Thank you by Admin


  • ariston servisi Monday, August 31, 2009

    php is needs hard working


  • general electric sevisi Monday, August 31, 2009

    i love php programming.


  • siemens servisi Monday, August 31, 2009

    asp is so good more than


  • band&#305;rma web tasar&#305;m&#305; Monday, August 31, 2009

    thanx a lot


  • Dmitry Tuesday, September 22, 2009

    Hello. I also have a problem with "PHPUnit (version ?.?.?) is too old, upgrade it if possible (the minimum version is 3.3.0)."

    Environment:

    Product Version: NetBeans IDE 6.7.1 (Build 200907230233)

    Java: 1.6.0_11; Java HotSpot(TM) 64-Bit Server VM 11.0-b16

    System: Windows Vista version 6.0 running on amd64; Cp1251; ru_RU (nb)

    Steps:

    - netbeans already installed

    - install php (from zip)

    - install phpunit from pear (3.4.0)

    - type C:\\php5\\php.exe as php interpreter

    - type C:\\php5\\phpunit.bat as phpunit script

    - add C:\\php5\\PEAR\\PHPUnit into global include path

    phpunit --version returns:

    PHPUnit 3.4.0 by Sebastian Bergmann.

    (in sources described as

    self::write(PHPUnit_Runner_Version::getVersionString() . "\\n\\n");)

    What i doing wrong?


  • buy cheap sexy lingerie online Monday, October 5, 2009

    Perfect.

    My developer had issues so I thought I'd be nice enough and see if I can help.

    I think this will do the trick


  • download movie hd Wednesday, October 28, 2009

    Thank you by Admin


  • links of london Thursday, October 29, 2009

    It was a very nice idea! Just wanna say thank you for the information you have shared. Just continue writing this kind of post. I will be your loyal reader. Thanks again.


  • web tasar&#305;m Tuesday, November 3, 2009

    thanks admin, great post..


  • hugo Sunday, December 20, 2009

    Hi, i have a same problem with Dmitry and Tobias.

    My netbean version is 6.8, phpunit ver 3.4.5

    What the solution ??

    Urgent !! Does netbean developer see the problem ?


  • Michiel Wednesday, January 6, 2010

    I also struggled with the version ?.?.? problem. I solved it by putting phpunit.bat instead of phpunit as the file path


  • ED Hardy Suit Saturday, February 6, 2010

    Hi, i have a same problem with Dmitry and Tobias.

    My netbean version is 6.8, phpunit ver 3.4.5

    What the solution ??


  • G.Marchwinski Friday, February 12, 2010

    Very, very nice tool :D but i found some bugs:

    - when i use "create php unit tests" i got fatal error because autoload do not work (probably bootstrap should be runned before). I have configured my own bootstrap.php to run all tests but i can not use generator and need to write all tests manualy.


  • pepper_bg Friday, February 26, 2010

    Regarding the G.Marchwinski comment above - you can set your bootstrap.php to be run during the PHP Unit Test generation if you pass a '--bootstrap your/bootstrap/location/bootstrap.php' at Tools->Options->PHP->Unit Testing->PHPUnit Script.

    I believe this is the only way to set custom paths to your external sources and all.


  • zijin Sunday, March 14, 2010

    Again regarding the G.Marchwinski and pepper_bg comment above, when using that method described by pepper_bg, make sure all the include paths set in the bootstrap are absolute paths.


  • G&ouml;r&uuml;nt&uuml;l&uuml; Chat Thursday, April 22, 2010

    when i use "create php unit tests" i got fatal error because autoload do not work (probably bootstrap should be runned before). I have configured my own bootstrap.php to run all tests but i can not use generator and need to write all tests manualy.


  • Pandora beads Sunday, May 2, 2010

    when using that method described by pepper_bg, make sure all the include paths set in the bootstrap are absolute paths.


  • MikeG0 Saturday, June 5, 2010

    RE: the problem described by Dmitry and Tobias ... you need to add /usr/share/php to your php path. The include directives in the PHPUnit files start with PHPUnit/ so /usr/share/php/PHPUnit in your include path wont work. FYI - I installed via an Ubuntu 10.04 package ... it should have handled this correctly, but oh well...

    For php5 create a file /etc/php5/conf.d/phpunit.ini and add to it ...

    [PHPUnit]

    include_path=${include_path} ":/usr/share/php"

    Restart apache and try again.


  • Gee0 Monday, June 7, 2010

    Im having the same problems as Tobias.

    a crazy idea which worked for me....

    In php.ini...make open_basedir =

    Yes, make "open_basedir equal nothing".

    check http://php.net/open-basedir if you care what side effects this will have.


  • Buz Monday, August 23, 2010

    possibility of sharing and social solidarity at a level just fine thank you


  • Colin Tuesday, August 30, 2011

    Just a note, I had the "PHPUnit (version ?.?.?) is too old, upgrade it if possible (the minimum version is 3.3.0)." problem mentioned above. The culprit turned-out to be my antivirus (Comodo), which was stopping NetBeans from retrieving the desired data.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.