[英]How to generate Tests in tests/ directory in PhpStorm?
PhpStorm has some sort of weird behaviour that is driving me crazy. PhpStorm有某种奇怪的行为让我发疯。 I've got my project setup to have a
source
and a test
directory. 我的项目设置
source
和test
目录。 The source
directory should be for productive code, while the test
directory should contain all the phpunit tests. source
目录应该是高效的代码,而test
目录应该包含所有的phpunit测试。
In those directories, the folder structure is mirrored - if I have a class \\foo\\Bar
, then there is src/foo/Bar.php
and test/foo/BarTest.php
. 在这些目录中,文件夹结构是镜像的 - 如果我有一个类
\\foo\\Bar
,那么有src/foo/Bar.php
和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. 我在PhpStorm中标记了
src/
和test/
作为源和测试目录,但是,每次我想为类创建一个新的测试套件时,PhpStorm默认将测试类放入该类旁边的src/
目录中测试。
It's possible to change that, however it get's more annoying when that same directory in test/
does not exist yet. 可以改变它,但是当
test/
中的相同目录还不存在时,它会变得更烦人。 Instead of creating it, PhpStorm will just reject to create that test suite for me. 而不是创建它,PhpStorm将拒绝为我创建该测试套件。
Maybe I am misunderstanding the concept behind test management in PhpStorm quite a bit - because it just can't be that bad user experience. 也许我误解了PhpStorm中测试管理背后的概念 - 因为它不会是那么糟糕的用户体验。
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). 最初IDE使用PHPUnit生成测试类的能力(当时这种功能是实际PHPUnit的一部分)。 Then PHPUnit creator(s) have moved this functionality into separate package (
phpunit-skelgen
) .. and you had to install it manually/separately. 然后PHPUnit创建者已将此功能移动到单独的包(
phpunit-skelgen
)..并且您必须手动/单独安装它。 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). 然后开发人员决定完全放弃phpunit-skelgen支持并实现当前实现(这也更符合在这些IDE支持的IDEA平台/技术上构建的其他IDE中的类似例程)。
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年发布以来,PHPStorm现在在指定的测试目录中进行测试,准确提供您在问题中要求的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.