Execute custom script instead of skelgen when test does not exist

Whenever I want to navigate to a test and it doesnt exist it asks if I want to generate test using PHPUnit Skeleton Generator.
I know sklegen itself is quite ok software, however it lacks a lot of custom options and requires extra setup (input) each time we create new test.

Is it maybe possible to set PHPStorm behaviour to not use skelgen but simply run any shell/php script?

Thanks,
Tomasz

9 comments

Hi Tomasz,

In PhpStorm v5 you can just use your own script (just name it the same way, I guess) -- you just need to support the same parameters .. but what is going to be inside is completely up to you. The custom dialog still will be show, but since you going to use your own implementation .. you should be able to leave all values at their defaults.

In upcoming PhpStorm v6 skelgen is no longer used -- everything is done inside PhpStorm and test case is just a file template (File | New | PHPUnit | PHPUnit test) -- it is very basic and you can configure it as desired at "Settings | File Templates".


Alternatively, you can always use External Tools functionality (Settings | External Tools)

0

Hi Andriy,

Thanks a lot for quick reply. That is indeed workaround, we will probably do it like that then.

You said that in v6 it will be done with File templates. Sounds good. I just have another question - maybe suggestion. Problem I had with skelgen was also that the path and filename of the test was not correctly detected. Will this be somehow improved in v6?

E.g.
(we use pear style namespaces)
class Foo_View_Simple (library/Foo/View/Simple.php) was put into library/Foo/View/Foo_View_Simple.php

Additionally the tests directory was in different location - I assume it should use this as root directory placing test into {$TESTS_DIRECTORY}/Foo/View/Simple.php

0
You said that in v6 it will be done with File templates. Sounds good. I just have another question - maybe suggestion. Problem I had with skelgen was also that the path and filename of the test was not correctly detected. Will this be somehow improved in v6?

You can try it yourself -- http://confluence.jetbrains.com/display/WI/Web+IDE+EAP

You can then submit your suggestions to the Issue Tracker (check for existing tickets first)

P.S.
Because it is still an EAP version (Early Access Program -- think about it as "Beta" version, kind of), it may contain misc bugs + some functionality may still be in the middle of implementing/refactoring etc (in other words -- try it on your own risk :)  -- but works good enough for me).

0

Just tried the latest release and testing the skeleton template feature, however as far as I can see it only generates the class declaration not the test method stubs?

Is there a reason why the test stubs are not created? This would be super useful and mean one doesnt have to type the methods out manually.

Thanks

Oli

0

As I understand: creating Test file is just a first step; Next step is to create test methods -- you can do it individually for each method (possibly few at once -- have not tested yet myself).

TBH -- I have not tried this yet myself and cannot say much. But I definitely liked usage of skelgen before (and you still can use it -- via External Tools functionality).

0

Right ok cool, glad its on the roadmap (using the built in functionality is easier as it requires less config) as having to manually create the tests is laborious :)

0
Right ok cool, glad its on the roadmap

When I said "first/next step" I meant -- you stand on your method you want to test, then invoke "Navigate | Test" and it will offer you to either jump to existing test or create new one. As far as I understand -- it should work for both classes and methods. If it only works for classes (creates new blablaTest.php file) then it is useless, unfortunately.

I do not think they will re-implement what skelgen did (generate whole file with all test methods already created) -- would be good though, otherwise too much manual typing indeed.

I can always fallback to using actual skelgen (and move generated file to a proper location manually) ... but that is not that convenient at all. Whatever...

0

I see.

When standing on the method to test and going to Navigate | Test it creates a blank class with no implemented methods.

What would be awesome, would be to implement something like the override or implement methods functionality, but for tests, allowing one to select the methods of the original class that you wish to test, and it automatically create a testX method for each selected method.

Oli

0

As suggested in this comment, you can semi-generate new test method (via "Code | Generate...") while standing in *Test class -- but it does not help much, since you still will have to type a bit.

Hopefully they will implement this for v6 (although I think it will not be in 6.0, maybe in 6.0.x): http://youtrack.jetbrains.com/issue/WI-16258

0

Please sign in to leave a comment.