10
10
のコマンドライン版テストランナーが起動します。
11
11
コマンドラインのテストランナーを使用したテストの様子を以下に示します。
12
12
13
- .. code-block :: bash
13
+ .. parsed-literal ::
14
14
15
15
$ phpunit ArrayTest
16
16
PHPUnit |version |.0 by Sebastian Bergmann and contributors.
@@ -74,66 +74,64 @@ PHPUnit は、*失敗 (failures)* と
74
74
75
75
以下のコードで、コマンドライン版テストランナーのオプションの一覧を見てみましょう。
76
76
77
- .. code-block :: bash
77
+ .. parsed-literal ::
78
78
79
79
$ phpunit --help
80
80
PHPUnit |version |.0 by Sebastian Bergmann and contributors.
81
81
82
- Usage: phpunit [options] UnitTest [UnitTest.php]
83
- phpunit [options] < directory>
82
+ Usage:
83
+ phpunit [options] UnitTest.php
84
+ phpunit [options] <directory>
84
85
85
86
Code Coverage Options:
86
-
87
87
--coverage-clover <file> Generate code coverage report in Clover XML format
88
88
--coverage-crap4j <file> Generate code coverage report in Crap4J XML format
89
89
--coverage-html <dir> Generate code coverage report in HTML format
90
90
--coverage-php <file> Export PHP_CodeCoverage object to file
91
- --coverage-text=< file> Generate code coverage report in text format
92
- Default: Standard output
91
+ --coverage-text=<file> Generate code coverage report in text format [default: standard output]
93
92
--coverage-xml <dir> Generate code coverage report in PHPUnit XML format
94
- --whitelist < dir> Whitelist < dir> for code coverage analysis
93
+ --coverage-cache <dir> Cache static analysis results
94
+ --warm-coverage-cache Warm static analysis cache
95
+ --coverage-filter <dir> Include <dir> in code coverage analysis
96
+ --path-coverage Perform path coverage analysis
95
97
--disable-coverage-ignore Disable annotations for ignoring code coverage
96
98
--no-coverage Ignore code coverage configuration
97
- --dump-xdebug-filter < file> Generate script to set Xdebug code coverage filter
98
99
99
100
Logging Options:
100
-
101
101
--log-junit <file> Log test execution in JUnit XML format to file
102
102
--log-teamcity <file> Log test execution in TeamCity format to file
103
103
--testdox-html <file> Write agile documentation in HTML format to file
104
104
--testdox-text <file> Write agile documentation in Text format to file
105
105
--testdox-xml <file> Write agile documentation in XML format to file
106
106
--reverse-list Print defects in reverse order
107
+ --no-logging Ignore logging configuration
107
108
108
109
Test Selection Options:
109
-
110
110
--filter <pattern> Filter which tests to run
111
- --testsuite < name,... > Filter which testsuite to run
112
- --group ... Only runs tests from the specified group(s)
113
- --exclude-group ... Exclude tests from the specified group(s)
111
+ --testsuite <name> Filter which testsuite to run
112
+ --group <name> Only runs tests from the specified group(s)
113
+ --exclude-group <name> Exclude tests from the specified group(s)
114
114
--list-groups List available test groups
115
115
--list-suites List available test suites
116
116
--list-tests List available tests
117
117
--list-tests-xml <file> List available tests in XML format
118
- --test-suffix ... Only search for test in files with specified
119
- suffix(es). Default: Test.php,.phpt
118
+ --test-suffix <suffixes> Only search for test in files with specified suffix(es). Default: Test.php,.phpt
120
119
121
120
Test Execution Options:
122
-
123
121
--dont-report-useless-tests Do not report tests that do not test anything
124
122
--strict-coverage Be strict about @covers annotation usage
125
123
--strict-global-state Be strict about changes to global state
126
124
--disallow-test-output Be strict about output during tests
127
125
--disallow-resource-usage Be strict about resource usage during small tests
128
126
--enforce-time-limit Enforce time limit based on test size
129
- --default-time-limit= < sec> Timeout in seconds for tests without @small, @medium or @large
127
+ --default-time-limit <sec> Timeout in seconds for tests without @small, @medium or @large
130
128
--disallow-todo-tests Disallow @todo-annotated tests
131
129
132
130
--process-isolation Run each test in a separate PHP process
133
131
--globals-backup Backup and restore $GLOBALS for each test
134
132
--static-backup Backup and restore static attributes for each test
135
133
136
- --colors= < flag> Use colors in output (" never" , " auto" or " always" )
134
+ --colors <flag> Use colors in output ("never", "auto" or "always")
137
135
--columns <n> Number of columns to use for progress output
138
136
--columns max Use maximum number of columns for progress output
139
137
--stderr Write to STDERR instead of STDOUT
@@ -144,39 +142,40 @@ PHPUnit は、*失敗 (failures)* と
144
142
--stop-on-risky Stop execution upon first risky test
145
143
--stop-on-skipped Stop execution upon first skipped test
146
144
--stop-on-incomplete Stop execution upon first incomplete test
147
- --fail-on-warning Treat tests with warnings as failures
145
+ --fail-on-incomplete Treat incomplete tests as failures
148
146
--fail-on-risky Treat risky tests as failures
147
+ --fail-on-skipped Treat skipped tests as failures
148
+ --fail-on-warning Treat tests with warnings as failures
149
149
-v|--verbose Output more verbose information
150
150
--debug Display debugging information
151
151
152
- --loader < loader> TestSuiteLoader implementation to use
153
152
--repeat <times> Runs the test(s) repeatedly
154
153
--teamcity Report test execution progress in TeamCity format
155
154
--testdox Report test execution progress in TestDox format
156
155
--testdox-group Only include tests from the specified group(s)
157
156
--testdox-exclude-group Exclude tests from the specified group(s)
157
+ --no-interaction Disable TestDox progress animation
158
158
--printer <printer> TestListener implementation to use
159
159
160
- --resolve-dependencies Resolve dependencies between tests
161
- --order-by= < order > Run tests in order: default | reverse | random | defects | depends
162
- --random-order-seed= < N > Use a specific random seed < N > for random order
163
- --cache-result Write run result to cache to enable ordering tests defects-first
160
+ --order-by <order> Run tests in order: default|defects|duration|no-depends|random|reverse|size
161
+ --random- order-seed <N > Use a specific random seed <N> for random order
162
+ --cache-result Write test results to cache file
163
+ --do-not- cache-result Do not write test results to cache file
164
164
165
165
Configuration Options:
166
-
167
166
--prepend <file> A PHP script that is included as early as possible
168
167
--bootstrap <file> A PHP script that is included before the tests run
169
168
-c|--configuration <file> Read configuration from XML file
170
169
--no-configuration Ignore default configuration file (phpunit.xml)
171
- --no-logging Ignore logging configuration
170
+ --extensions <extensions> A comma separated list of PHPUnit extensions to load
172
171
--no-extensions Do not load PHPUnit extensions
173
172
--include-path <path(s)> Prepend PHP's include_path with given path(s)
174
- -d key[=value] Sets a php.ini value
173
+ -d <key[=value]> Sets a php.ini value
174
+ --cache-result-file <file> Specify result cache path and filename
175
175
--generate-configuration Generate configuration file with suggested settings
176
- --cache-result-file==<FILE> Specify result cache path and filename
176
+ --migrate-configuration Migrate configuration file to current format
177
177
178
178
Miscellaneous Options:
179
-
180
179
-h|--help Prints this usage information
181
180
--version Prints the version and exits
182
181
--atleast-version <min> Checks that version is greater than min and exits
@@ -202,49 +201,32 @@ PHPUnit は、*失敗 (failures)* と
202
201
``--coverage-clover ``
203
202
204
203
テスト結果から XML 形式のログファイルを作成し、
205
- コードカバレッジ情報もそこに含めます。
206
- 詳細は :ref:`logging` を参照ください。
207
-
208
- この機能は、tokenizer 拡張モジュールおよび Xdebug
209
- 拡張モジュールがインストールされている場合にのみ使用可能となることに注意しましょう。
204
+ コードカバレッジ情報もそこに含めます。詳細は
205
+ :ref: `code-coverage-analysis ` を参照ください。
210
206
211
207
``--coverage-crap4j ``
212
208
213
209
コードカバレッジレポートを Crap4j 形式で作成します。詳細は
214
210
:ref: `code-coverage-analysis ` を参照ください。
215
211
216
- この機能は、tokenizer 拡張モジュールおよび Xdebug
217
- 拡張モジュールがインストールされている場合にのみ使用可能となることに注意しましょう。
218
-
219
212
``--coverage-html ``
220
213
221
214
コードカバレッジレポートを HTML 形式で作成します。詳細は
222
215
:ref: `code-coverage-analysis ` を参照ください。
223
216
224
- この機能は、tokenizer 拡張モジュールおよび Xdebug
225
- 拡張モジュールがインストールされている場合にのみ使用可能となることに注意しましょう。
226
-
227
217
``--coverage-php ``
228
218
229
219
シリアライズした PHP_CodeCoverage オブジェクトを生成し、
230
220
コードカバレッジ情報もそこに含めます。
231
221
232
- この機能は、tokenizer 拡張モジュールおよび Xdebug
233
- 拡張モジュールがインストールされている場合にのみ使用可能となることに注意しましょう。
234
-
235
222
``--coverage-text ``
236
223
237
224
テストを実行したときに、ログファイルあるいはコマンドライン出力で
238
225
可読形式のコードカバレッジ情報を生成します。
239
- 詳細は :ref:`logging` を参照ください。
240
-
241
- この機能は、tokenizer 拡張モジュールおよび Xdebug
242
- 拡張モジュールがインストールされている場合にのみ使用可能となることに注意しましょう。
243
226
244
227
``--log-junit ``
245
228
246
229
JUnit XML フォーマットを使用して、テストの実行結果のログを作成します。
247
- 詳細は :ref:`logging` を参照ください。
248
230
249
231
``--testdox-html `` および ``--testdox-text ``
250
232
@@ -281,10 +263,10 @@ PHPUnit は、*失敗 (failures)* と
281
263
:name: textui.examples.TestCaseClass.php
282
264
283
265
<?php
284
- use PHPUnit\Framework\TestCase;
285
-
286
266
namespace TestNamespace;
287
267
268
+ use PHPUnit\Framework\TestCase;
269
+
288
270
class TestCaseClass extends TestCase
289
271
{
290
272
/**
@@ -508,7 +490,7 @@ PHPUnit は、*失敗 (failures)* と
508
490
:file: `phpunit.xml ` あるいは
509
491
:file: `phpunit.xml.dist ` (この順番で使用します)
510
492
が現在の作業ディレクトリに存在しており、かつ ``--configuration ``
511
- が使われて* いない* 場合、設定が自動的にそのファイルから読み込まれます。
493
+ が使われて *いない * 場合、設定が自動的にそのファイルから読み込まれます。
512
494
513
495
指定されているのがディレクトリで、
514
496
:file: `phpunit.xml ` あるいは
@@ -530,7 +512,9 @@ PHPUnit は、*失敗 (failures)* と
530
512
531
513
.. admonition :: Note
532
514
533
- PHPUnit 4.8 以降では、これらのオプションを引数の後にも指定できるようになりました。
515
+ これらのオプションは、引数の後に指定することもできます。
516
+
517
+ .. _textui.testdox :
534
518
535
519
TestDox
536
520
#######
@@ -546,9 +530,9 @@ PHPUnit の TestDox 機能は、テストクラス内のすべてのテストメ
546
530
547
531
``BankAccount `` クラスのアジャイルな文書を見てみましょう。
548
532
549
- .. code-block:: bash
533
+ .. parsed-literal ::
550
534
551
- $ phpunit --testdox BankAccountTest
535
+ $ phpunit --testdox BankAccountTest.php
552
536
PHPUnit |version |.0 by Sebastian Bergmann and contributors.
553
537
554
538
BankAccount
0 commit comments