douzou7012 2018-03-12 23:47
浏览 234

如何通过phpunit.xml在测试套件中包含/排除某些组

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.

  • 写回答

1条回答 默认 最新

  • dongluni0568 2018-03-13 00:02
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献