duanhui1869 2016-06-14 19:05
浏览 41
已采纳

默认情况下在PHPUnit中运行单个测试套件

My PHPUnit configuration file has two test suites, unit and system. When I run the test runner vendor/bin/phpunit, it runs all tests in both suites. I can target a single suite with the testsuite flag: vendor/bin/phpunit --testsuite unit, but I need to configure the test runner to run only the unit suite by default, and to run integration only when specifically called with the testsuite flag.

My configuration:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true">
  <testsuites>
    <testsuite name="unit">
      <directory>tests/Unit</directory>
    </testsuite>
    <testsuite name="integration">
      <directory>tests/Integration</directory>
    </testsuite>
  </testsuites>
  <filter>
    <whitelist>
      <directory suffix=".php">src</directory>
    </whitelist>
  </filter>
  <logging>
    <log type="coverage-clover" target="build/clover.xml"/>
  </logging>
</phpunit>
  • 写回答

2条回答 默认 最新

  • doutao6653 2016-06-14 20:44
    关注

    There doesn't appear to be a way to list multiple testsuites from a phpunit.xml file, but then only run one. However, if you do have some control over a fuller integration and testing environment where you can configure things more exactly, you can have more than one phpunit configuration files, and set one (or more) with more involved environments to set the command-line parameter --configuration <file> option with a configuration that will do more. This at least makes sure that the simplest config will run in the easiest fashion.

    The two files can be called whatever you like if you run them specifically, but it may be worth thinking about having the quick-to-run file called the default phpunit.xml, and the specifically named and extended filem as phpunit.xml.dist. The .dist file will be automatically run by default if the original plain .xml does not exist. Another option is to have the phpunit.xml.dist file in a code repository, but then copy it to a phpunit.xml file, with less testsuite's, which is not in itself checked into version control, and is only kept locally (it would probably also be marked as ignored in a .gitignore file, or similar).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵