命令行选项

让我们来瞧瞧以下代码中命令行测试运行器的各种选项:phpunit --help

PHPUnit 5.7.0 by Sebastian Bergmann and contributors.

Usage: phpunit [options] UnitTest [UnitTest.php]

phpunit [options]

Code Coverage Options:

--coverage-clover Generate code coverage report in Clover XML format.

--coverage-crap4j Generate code coverage report in Crap4J XML format.

--coverage-html

--coverage-php Export PHP_CodeCoverage object to file.

--coverage-text= Generate code coverage report in text format.

Default: Standard output.

--coverage-xml

--whitelist

--disable-coverage-ignore Disable annotations for ignoring code coverage.

Logging Options:

--log-junit Log test execution in JUnit XML format to file.

--log-teamcity Log test execution in TeamCity format to file.

--testdox-html Write agile documentation in HTML format to file.

--testdox-text Write agile documentation in Text format to file.

--testdox-xml Write agile documentation in XML format to file.

--reverse-list Print defects in reverse order

Test Selection Options:

--filter Filter which tests to run.

--testsuite Filter which testsuite to run.

--group ... Only runs tests from the specified group(s).

--exclude-group ... Exclude tests from the specified group(s).

--list-groups List available test groups.

--list-suites List available test suites.

--test-suffix ... Only search for test in files with specified

suffix(es). Default: Test.php,.phpt

Test Execution Options:

--report-useless-tests Be strict about tests that do not test anything.

--strict-coverage Be strict about @covers annotation usage.

--strict-global-state Be strict about changes to global state

--disallow-test-output Be strict about output during tests.

--disallow-resource-usage Be strict about resource usage during small tests.

--enforce-time-limit Enforce time limit based on test size.

--disallow-todo-tests Disallow @todo-annotated tests.

--process-isolation Run each test in a separate PHP process.

--no-globals-backup Do not backup and restore $GLOBALS for each test.

--static-backup Backup and restore static attributes for each test.

--colors= Use colors in output ("never", "auto" or "always").

--columns Number of columns to use for progress output.

--columns max Use maximum number of columns for progress output.

--stderr Write to STDERR instead of STDOUT.

--stop-on-error Stop execution upon first error.

--stop-on-failure Stop execution upon first error or failure.

--stop-on-warning Stop execution upon first warning.

--stop-on-risky Stop execution upon first risky test.

--stop-on-skipped Stop execution upon first skipped test.

--stop-on-incomplete Stop execution upon first incomplete test.

--fail-on-warning Treat tests with warnings as failures.

--fail-on-risky Treat risky tests as failures.

-v|--verbose Output more verbose information.

--debug Display debugging information during test execution.

--loader TestSuiteLoader implementation to use.

--repeat Runs the test(s) repeatedly.

--teamcity Report test execution progress in TeamCity format.

--testdox Report test execution progress in TestDox format.

--testdox-group Only include tests from the specified group(s).

--testdox-exclude-group Exclude tests from the specified group(s).

--printer TestListener implementation to use.

Configuration Options:

--bootstrap A "bootstrap" PHP file that is run before the tests.

-c|--configuration Read configuration from XML file.

--no-configuration Ignore default configuration file (phpunit.xml).

--no-coverage Ignore code coverage configuration.

--no-extensions Do not load PHPUnit extensions.

--include-path Prepend PHP's include_path with given path(s).

-d key[=value] Sets a php.ini value.

--generate-configuration Generate configuration file with suggested settings.

Miscellaneous Options:

-h|--help Prints this usage information.

--version Prints the version and exits.

--atleast-version Checks that version is greater than min and exits.

phpunit UnitTest运行由 UnitTest 类提供的测试。这个类应当在 UnitTest.php 源文件中声明。

UnitTest 这个类必须满足以下二个条件之一:要么它继承自 PHPUnit\Framework\TestCase;要么它提供 public static suite() 方法,这个方法返回一个 PHPUnit_Framework_Test 对象,比如,一个 PHPUnit_Framework_TestSuite 类的实例。phpunit UnitTest UnitTest.php运行由 UnitTest 类提供的测试。这个类应当在指定的源文件中声明。--coverage-clover为运行的测试生成带有代码覆盖率信息的 XML 格式的日志文件。更多细节请参见第 13 章。

请注意,此功能仅当安装了 tokenizer 和 Xdebug 这两个 PHP 扩展后才可用。--coverage-crap4j生成 Crap4j 格式的代码覆盖率报告。更多细节请参见第 11 章。

请注意,此功能仅当安装了 tokenizer 和 Xdebug 这两个 PHP 扩展后才可用。--coverage-html生成 HTML 格式的代码覆盖率报告。更多细节请参见 第 11 章。

请注意,此功能仅当安装了 tokenizer 和 Xdebug 这两个 PHP 扩展后才可用。--coverage-php生成一个序列化后的 PHP_CodeCoverage 对象,此对象含有代码覆盖率信息。

请注意,此功能仅当安装了 tokenizer 和 Xdebug 这两个 PHP 扩展后才可用。--coverage-text为运行的测试以人们可读的格式生成带有代码覆盖率信息的日志文件或命令行输出。更多细节请参见 第 13 章。

请注意,此功能仅当安装了 tokenizer 和 Xdebug 这两个 PHP 扩展后才可用。--log-junit为运行的测试生成 JUnit XML 格式的日志文件。更多细节请参见 第 13 章。--log-tap--log-json生成 JSON 格式的日志文件。更多细节请参见第 13 章。--testdox-html 和 --testdox-text为运行的测试以 HTML 或纯文本格式生成敏捷文档。更多细节请参见 第 12 章。--filter只运行名称与给定模式匹配的测试。如果模式未闭合包裹于分隔符,PHPUnit 将用 / 分隔符对其进行闭合包裹。

测试名称将以以下格式之一进行匹配:

TestNamespace\TestCaseClass::testMethod默认的测试名称格式等价于在测试方法内使用 __METHOD__ 魔术常量。TestNamespace\TestCaseClass::testMethod with data set #0当测试拥有数据供给器时,数据的每轮迭代都会将其当前索引附加在默认测试名称结尾处。TestNamespace\TestCaseClass::testMethod with data set "my named data"当测试拥有使用命名数据集的数据供给器时,数据的每轮迭代都会将当前名称附加在默认测试名称结尾处。命名数据集的例子参见例 3.1。

例 3.1: 命名数据集

use PHPUnit\Framework\TestCase;

namespace TestNamespace;

class TestCaseClass extends TestCase

{

/**

* @dataProvider provider

*/

public function testMethod($data)

{

$this->assertTrue($data);

}

public function provider()

{

return [

'my named data' => [true],

'my data' => [true]

];

}

}

?>/path/to/my/test.phpt对于 PHPT 测试,其测试名称是文件系统路径。

有效的过滤器模式例子参见例 3.2。

例 3.2: 过滤器模式例子

--filter 'TestNamespace\\TestCaseClass::testMethod'

--filter 'TestNamespace\\TestCaseClass'

--filter TestNamespace

--filter TestCaseClass

--filter testMethod

--filter '/::testMethod .*"my named data"/'

--filter '/::testMethod .*#5$/'

--filter '/::testMethod .*#(5|6|7)$/'

在匹配数据供给器时有一些额外的快捷方式,参见例 3.3。

例 3.3: 过滤器的快捷方式

--filter 'testMethod#2'

--filter 'testMethod#2-4'

--filter '#2'

--filter '#2-4'

--filter 'testMethod@my named data'

--filter 'testMethod@my.*data'

--filter '@my named data'

--filter '@my.*data'--testsuite只运行名称与给定模式匹配的测试套件。--group只运行来自指定分组(可以多个)的测试。可以用 @group 标注为测试标记其所属的分组。

@author 标注是 @group 的一个别名,允许按作者来筛选测试。--exclude-group排除来自指定分组(可以多个)的测试。可以用 @group 标注为测试标记其所属的分组。--list-groups列出所有有效的测试分组。--test-suffix只查找文件名以指定后缀(可以多个)结尾的测试文件。--report-useless-tests更严格对待事实上不测试任何内容的测试。详情参见 第 6 章。--strict-coverage更严格对待意外的代码覆盖。详情参见 第 6 章。--strict-global-state更严格对待全局状态篡改。详情参见 第 6 章。--disallow-test-output更严格对待测试执行期间产生的输出。详情参见第 6 章。--disallow-todo-tests不执行文档注释块中含有 @todo 标注的测试。--enforce-time-limit根据测试规模对其加上执行时长限制。详情参见第 6 章。--process-isolation每个测试都在独立的PHP进程中运行。--no-globals-backup不要备份并还原 $GLOBALS。更多细节请参见“全局状态”一节。--static-backup备份并还原用户定义的类中的静态属性。更多细节请参见“全局状态”一节。--colors使用彩色输出。Windows下,用 ANSICON 或 ConEmu。

本选项有三个可能的值:

never: 完全不使用彩色输出。当未使用 --colors 选项时,这是默认值。

auto: 如果当前终端不支持彩色、或者输出被管道输出至其他命令、或输出被重定向至文件时,不使用彩色输出,其余情况使用彩色。

always: 总是使用彩色输出,即使当前终端不支持彩色、输出被管道输出至其他命令、或输出被重定向至文件。

当使用了 --colors 选项但未指定任何值时,将选择 auto 做为其值。--columns定义输出所使用的列数。如果将其值定义为 max,则使用当前终端所支持的最大列数。--stderr选择输出到 STDERR 而非 STDOUT.--stop-on-error首次错误出现后停止执行。--stop-on-failure首次错误或失败出现后停止执行。--stop-on-risky首次碰到有风险的测试时停止执行。--stop-on-skipped首次碰到跳过的测试时停止执行。--stop-on-incomplete首次碰到不完整的测试时停止执行。--verbose输出更详尽的信息,例如不完整或者跳过的测试的名称。--debug输出调试信息,例如当一个测试开始执行时输出其名称。--loader指定要使用的 PHPUnit_Runner_TestSuiteLoader 实现。

标准的测试套件加载器将在当前工作目录和 PHP 的 include_path 配置指令中指定的每个目录内查找源文件。诸如 Project_Package_Class 这样的类名对应的源文件名为 Project/Package/Class.php。--repeat将测试重复运行指定次数。--tap--testdox将测试进度以敏捷文档方式报告。更多细节请参见 第 12 章。--printer指定要使用的结果输出器(printer)。输出器类必须扩展 PHPUnit_Util_Printer 并且实现 PHPUnit_Framework_TestListener 接口。--bootstrap在测试前先运行一个 "bootstrap" PHP 文件。--configuration,-c从 XML 文件中读取配置信息。更多细节请参见附录 C。

如果 phpunit.xml 或 phpunit.xml.dist (按此顺序)存在于当前工作目录并且未使用 --configuration,将自动从此文件中读取配置。--no-configuration忽略当前工作目录下的 phpunit.xml 与 phpunit.xml.dist。--include-path向 PHP 的 include_path 开头添加指定路径(可以多个)。-d设置指定的 PHP 配置选项的值。

注意

请注意,从 4.8 开始,选项不能放在参数之后。

php命令行测试模块,PHPUnit相关推荐

  1. python:argparse命令行解析模块详解

    argparse命令行解析模块学习 import argparse parser = argparse.ArgumentParser() #类似于初始化吧 parser.parse_args() #解 ...

  2. I.MX6 Android CAN 命令行测试

    /********************************************************************** I.MX6 Android CAN 命令行测试* 说明: ...

  3. 安装jdk配置环境、cmd命令行测试环境变量配置是否正确及运行java程序、安装IDEA编写代码测试

    文章目录 1.安装jdk配置环境 2.cmd命令行测试环境变量配置是否正确及运行java程序 3.安装IDEA编写代码测试 1.安装jdk配置环境 首先打开官网Oracle https://www.o ...

  4. linux bt测试命令,Android命令行测试BT,WIFI,Sensor工作状态

    //命令行测试wlan //加载驱动 #insmod /system/lib/modules/ath6kl/cfg80211.ko #insmod /system/lib/modules/ath6kl ...

  5. Android命令行测试BT WiFi Sensor工作状态

    //命令行测试wlan //加载驱动 #insmod /system/lib/modules/ath6kl/cfg80211.ko #insmod /system/lib/modules/ath6kl ...

  6. (OK) Android命令行测试BT,WIFI,Sensor工作状态 — svc

    http://blog.chinaunix.net/uid-25909619-id-3554423.html //命令行测试wlan //加载驱动 #insmod /system/lib/module ...

  7. 命令行测试BT,WIFI,Sensor工作状态

    //命令行测试wlan //加载驱动 #insmod /system/lib/modules/ath6kl/cfg80211.ko #insmod /system/lib/modules/ath6kl ...

  8. 命令行测试网速_3个方便的命令行互联网速度测试

    命令行测试网速 能够验证网络连接速度使您可以控制计算机. 可以通过命令行检查Internet和网络速度的三个开源工具是Speedtest,Fast和iPerf. 速度测试 Speedtest是一个古老 ...

  9. python 命令行 解析模块 optparse、argparse

    optparse:https://docs.python.org/zh-cn/3/library/optparse.html argparse :https://docs.python.org/zh- ...

最新文章

  1. WinForm 设置初始位置在屏幕右下角
  2. java基础---JVM---java内存区域与内存溢出问题
  3. 爬虫-基于bs4库的HTML内容查找方法
  4. Windows核心编程 第2 4章 异常处理程序和软件异常
  5. C++流操纵算子(格式控制)
  6. proto的介绍和基础使用
  7. H5 页面列表缓存方案
  8. IntelliJ IDEA for Mac如何管理SDK/JDK,模块如何设置SDK/JDK?
  9. python量化数据处理小细节2
  10. java中的浮点数相加
  11. php 单一职责,单一职责原则
  12. ionic中定义路由的问题
  13. VMware虚拟机XP系统安装图文教程
  14. poi合并单元格的处理
  15. 验证数据是否满足正态分布——Q-Q图和P-P图
  16. Java学生学籍管理系统
  17. 每日分享(采集网站访客流量统计程序)
  18. 二手车交易价格预测 (数据分析)————task(2)
  19. ios 连续点击button_iOS小技巧:用runtime 解决UIButton 重复点击问题
  20. 7-3 五彩斑斓的黑 (20 分)(C语言实现)

热门文章

  1. 浏览器为低版本IE的时候的信息提示;旧版 Internet Explorer 升级提示页;旧版 Internet Explorer 淘汰行动
  2. 【用ArcGIS制作一张好看的中国月度气温图
  3. LTE小区重选和重定向
  4. winform picturebox 图片布满
  5. python打印dict,Python之print字典
  6. 怎么准备数学考研复试
  7. 【android】id cannot be resolved or is not a field
  8. shiro反序列化漏洞修复
  9. linux mint方便快捷安装android studio
  10. Navicat:设置Oracle数据库主键自增