How to generate Tests in tests/ directory in PhpStorm?
PhpStorm has some sort of weird behaviour that is driving me crazy. I've got my project setup to have a source
and a test
directory. The source
directory should be for productive code, while the test
directory should contain all the phpunit tests.
In those directories, the folder structure is mirrored - if I have a class fooBar
, then there is src/foo/Bar.php
and test/foo/BarTest.php
.
I've marked src/
and test/
as source and test directory in PhpStorm, however, every time I want to create a new test suite for a class, PhpStorm defaults to put the test class into the src/
directory next to the class under test.
It's possible to change that, however it get's more annoying when that same directory in test/
does not exist yet. Instead of creating it, PhpStorm will just reject to create that test suite for me.
Maybe I am misunderstanding the concept behind test management in PhpStorm quite a bit - because it just can't be that bad user experience.
Is there something I am doing wrong, or something that I can configure to make the situation less painful?
You are doing nothing wrong. It just does not work this way -- devs coded it to behave in a way it is right now.
Originally IDE used PHPUnit's ability to generate test classes (back then such functionality was part of actual PHPUnit). Then PHPUnit creator(s) have moved this functionality into separate package ( phpunit-skelgen
) .. and you had to install it manually/separately. Then devs decided to drop phpunit-skelgen support completely and implemented current implementation (which is also more in line with similar routines in other IDEs built on IDEA platform/technologies supported by those IDEs).
There are quite few tickets about changing such behaviour to the same as you described/desired .. but so far it does not look like it's in their priority list...
Subscribe to those tickets (star/vote/comment) to get notified on progress.
从发行版2016.3开始,PHPStorm现在可以在指定的测试目录中进行测试,从而准确提供您在问题中所要求的内容。
链接地址: http://www.djcxy.com/p/87360.html上一篇: 为什么c ++容器不能执行擦除(反向)