PHP in Action Rotating Header Image

Running PHP tests inside Vim

I created my own test runner to run tests inside Vim, I can’t remember how long ago. Must be a year or two. I never shared it with the world. It was too primitive for anyone else to use. Then, recently, I decided to try re-implementing it in a more serious way. That meant using a more sophisticated programming language. Vim script has seen some improvements and is pretty useful for simple tasks, but I want something that’s object-oriented and has a test framework. That means Perl, Python or Ruby, all of which are available from inside Vim. So I’ve started doing it in Ruby.

It’s not ready for public consumption yet, but I think it will be eventually. Here’s what it looks like at the moment:

vimtestrun

This is how I program about 90 per cent of the time: the test case and the class I’m testing side by side and a small extra window to show the test results. I can run the test by pressing F11 (which just happened to be the key that was available at the time). I work test-first, so before implementing something on the left, I have to write another test on the right. It’s less tempting to start implementing without tests when there’s an easy way to run the tests.

Share/Save/Bookmark

11 Comments

  1. Carl says:

    Wow, this is great! I can’t wait to get my hands on this implentation :-)

    Carl

  2. dagfinn says:

    Thanks, I’ll try even harder to find the time to get it ready for prime time.

  3. mod rewrite says:

    I use only Eclipse.. vim is to complicated.

  4. GameOn says:

    This looks awesome, just don’t rush it, make it how you want it!

  5. dagfinn says:

    If Vim is too complicated, there is an “easy mode” that makes for more “normal” editing.

    For example:

    http://www.linux.com/articles/60991

  6. mod rewrite says:

    Eclipse is better.. I use linux but vim for projects? Never.

  7. I would still like to see PHPUnit support in that vim plugin of yours :)

  8. dagfinn says:

    There is support for PHPUnit. I just haven’t released the plugin yet. The only really difficult task I have left is getting it to work with Vim sessions. Running PHPUnit is simple by comparison.

  9. I can’t wait for this to be released Dagfinn :)

    I use vim and phpunit alot each and every day.

  10. Kris Day says:

    Hi,
    I am leaning vim and it is a blast. This would be a great addition.
    PS – I read your book and it was excellent. I’m an English major coming from the land of marketing and studying PHP to start a second career. Nice use of metaphor, well constructed, well edited. Good job. Really!

  11. Corey Winkelmann says:

    Hey dagfinn,

    I came across this and was wondering if you have finished this plugin for vim. This would be amazing as I am using vim as my php editor. I would like to be able to do the TDD approach to coding which is what it looks like this tool would be amazing at.

Leave a Reply