Save Tests in the Test Directory

Hi everyone,
I thought I'd ask this question in the forums before turning to the issue tracker to file a feature requests. I'd like to have my test directory be the default output directory when creating unit tests. Is there any way of doing that?

5 comments
Comment actions Permalink

Hi Sean,

Unfortunately not -- only manually by editing the target path every time.

0
Comment actions Permalink

It's disapointing those requests didn't gain much traction. This seems like an obvious change, and I can't imagine anyone keeps their tests in the same directory as the code/class being tested. Generating unit tests would be a two click operation with this change.

0
Comment actions Permalink

Well .. what can I say. It is surely annoying to change the target path every time when working with PHPUnit files (creating them) a lot (used it myself -- not a fan of it). On another hand -- I do not create new test file every 5 mins, so not a huge deal.

At the same time -- it does not look too difficult to fix it (from end user point of view) if configuration is in place (e.g. tests folder is marked as "Tests Sources Root") ... but I currently do not see clear/safe way of detecting the final path unless some assumptions are made (what I mean -- not everyone uses root/classes/foo/foo.php --> root/tests/classes/foo/fooTest.php convention; there are variations) -- maybe (Q for devs) it will be worth bringing "Sources Root" from IntelliJ IDEA (blue coloured folder icon) to mark such folder as sources (so that mapping will be root/SOURCES_ROOT/foo/foo.php --> root/TESTS_SOURCES_ROOT/SOURCES_ROOT/foo/footest.php)?

0
Comment actions Permalink

I have to agree creating unit tests isn't something I do dozens of times a day, and my request is more of a "wouldn't it be nice if..." type of thing, rather than being a must have feature. I guess I'm not entirely sure what purpose is served by marking a directory as the "Tests" directory, if that doesn't mean automatically saving the unit tests there.

0
Comment actions Permalink

When you will start to work with unit tests a bit more in PhpStorm, you will eventually discover where it is used. For example:

  • Tests scope
  • When displaying/filtering out coverage data
  • etc
0

Please sign in to leave a comment.