NetBeans is TDD unfriendly!

Posted by John Kleijn • Monday, March 29. 2010 • Category: TDD

I am getting soo tired of Zend Studio for Eclipse. On large projects, or rather projects with large libs (e.g. Zend Framework and Doctrine) code suggest and "building" is just too slow. It is since about a month impossible to blame hardware imitations either.


Goliath (my workstation in a massive Lian Li case, with three monitors making for a 6144x1152px desktop) has been fitted with a Xeon W3570 and 24 GB of ECC memory:

So throwing more hardware at it is just not going to work. There is apparently something fundamentally wrong with ZSfE. One of the reasons I've stuck with it has been the PHPUnit integration. You can, of course, run your Unit Tests in a console, but the integration in Zend Studio adds value more than a pretty graphical interface: it allows quick navigation to failing tests and errors from the console window (hyperlinked, which opens the file in the editor). But the PHPUnit integration in ZSfE doesn't work with namespaced tests case classes. Actually you can hack into ZendPHPUnit.php (e.g. "plugins/com.zend.php.phpunit_7.1.1.v20091227-1310/resources/ZendPHPUnit.php"), the IDE's custom bootstrap, and the tests will at least run, but you lose the navigation to test functionality.

Aside from that, you don't buy upper segment hardware to have to wait for code hints, or for your IDE to freeze up for several minutes while it's "building". Inexcusable, sorry.

So many people have recommended NetBeans, which I did try before. I didn't recall why I rejected it the first time, but it became apparent quickly: the integration of PHPUnit is TDD unfriendly. And very restrictive. Basically NetBeans requires the de facto standard for organixing tests in PHP. You know, say I've got a "kwd\foo\bar\Meh" class in "workspace\foo", then the testcase is found in "workspace\foo\tests\kwd\foo\bar\MehTest.php". I know that works for many people, but I prefer to have the same testcase in "workspace\foo\kwd\foo\tests\bar\MehTest.php". Yes, inside the library. As far as I'm concerned, the test case is part of the library, this especially makes sense when namespacing. So how does NetBeans force its wicked ways on me? Simply by not giving me another option: I have to right-click on the class I want to test, not the test case in order to run the test!

And therein lies the larger issue, you can't as I've been doing in Zend Studio, create a test, run it and create the test case and it's contents as needed. You have to decide what class you are going to make first, then create the test case. This forces a premature decision, as well as "one test per class". It seems pretty clear that in this IDE, the test is not and can not be the centerpoint of development.

In all fairness, I haven't spent a whole lot of time with this IDE yet, so perhaps I am overlooking something. Perhaps not. And to add some positive critique as well, I do like the IDE as a whole. In particular the fact that is uses the system's binaries instead of bundled ones. With ZSfE, you have to manage separate configurations, and there are version issues. For example it is possible that the subversion version Eclipse uses is not compatible with you system's, causing issues when you want to use the command line.

Anyway, since lately I've been using PHPUnit from the console anyway, NetBeans is most likely going to be my new IDE. Bye bye Zend Studio, you screwed up royally.

0 Trackbacks

  1. No Trackbacks

3 Comments

Display comments as (Linear | Threaded)
  1. Thanks for your post. I was wondering why NB always failed to find my tests. As you explain, the test for MyClass must also be named MyClass, but located within the /tests folder. Like you, I prefer to have my test class named MyClassTest, though I am perfectly happy to place it in a separate hierarchy in the /tests folder.

    I confess that I am not doing much pure TDD, so I usually do have my SUT class already defined, if not completely written. So, as you observe, I can run tests by doing a right-click Run on the Test file itself, provided NB is pointed to the right test bootstrap file.

    Now to figure out why my tests run so slowly, even via this method.

    Thanks and cheers!

  2. No problem. It seems though as if my verdict of Zend Studio was premature. I'm starting to have similar issues with NetBeans, which probably means the issue with Java on Ubuntu, rather than with either IDEs. :-(

  3. Right, I'm on WinXP, so it's probably the Java slowing up the works. My PHP unit tests run significantly faster from command line (no surprise). Cheers!

Add Comment

You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA


Antiquities and such