问题描述
我想从测试套件中排除或包含某些测试.我想通过注释/组对此进行一些控制,而不是在 phpunit.xml
我尝试过类似的操作,但它似乎忽略了 和/或
<测试套件名称=单元"><目录>单元</目录></testsuite><测试套件名称="IntegrationFirstRound"><目录>集成/</目录><include><!-- 我只想包含这个组--><组>第一轮</组></包括></testsuite><测试套件名称="IntegrationOther"><目录>集成/</目录><exclude><!-- 我想排除这个组,运行所有其他组--><组>第一轮</组></排除></testsuite></testsuites>
我不想仅仅为了适应这一点而将测试移动到不同的文件夹,并且我不想从 CLI 多次调用 phpunit,我希望我可以通过 xml 配置获得所需的结果.
好吧,看看 DOC,这应该是你第一个看的地方
https://phpunit.de/manual/current/en/appendixes.配置.html
您需要一个 groups
元素,其中包含 group
.所以你在哪里
<组>第一轮</组></排除>
你应该有
<exclude><!-- 我想排除这个组,运行所有其他组--><组>第一轮</组></排除></组>
它并没有真正说明它是否应该放在 <testsuite>
中,我从未使用过它,但我相信如果您查看文档,您应该会找到一些示例.>
I would like to exclude or include certain test from test-suites. I would like to have some control of this via annotations/groups rather than naming specific files or folders in phpunit.xml
I have attempted something like this, but its appears to be ignoring the <groups>
and/or <include>
<testsuites>
<testsuite name="Unit">
<directory>Unit</directory>
</testsuite>
<testsuite name="IntegrationFirstRound">
<directory>Integration/</directory>
<include><!-- I want to ONLY include this group -->
<group>first-round</group>
</include>
</testsuite>
<testsuite name="IntegrationOther">
<directory>Integration/</directory>
<exclude><!-- I want to EXCLUDE this group, run all others -->
<group>first-round</group>
</exclude>
</testsuite>
</testsuites>
I don't want to move tests to different folders just to accommodate this, and I do not want to invoke phpunit multiple times from the CLI, I am hoping I can achieve the desired results via the xml config.
Ok, looking at the DOCs which should be the first place you look
https://phpunit.de/manual/current/en/appendixes.configuration.html
You need a groups
element with the group
inside of it. So where you have
<exclude><!-- I want to EXCLUDE this group, run all others -->
<group>first-round</group>
</exclude>
You should have
<groups>
<exclude><!-- I want to EXCLUDE this group, run all others -->
<group>first-round</group>
</exclude>
</groups>
It doesn't really say if it should go inside the <testsuite>
, and I never used it but I am sure if you look in the documentation you should find some examples.
这篇关于如何通过 phpunit.xml 从测试套件中包含/排除某些组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!