@@ -235,8 +235,7 @@ the following code:
235
235
``--testdox-html`` and ``--testdox-text``
236
236
237
237
Generates agile documentation in HTML or plain text format for the
238
- tests that are run. See :ref:`other-uses-for-tests` for
239
- more details.
238
+ tests that are run (see :ref:`textui.testdox`).
240
239
241
240
``--filter``
242
241
@@ -459,8 +458,7 @@ the following code:
459
458
460
459
` ` --testdox` `
461
460
462
- Reports the test progress as agile documentation. See
463
- :ref:` other-uses-for-tests` for more details.
461
+ Reports the test progress in TestDox format (see :ref:` textui.testdox` ).
464
462
465
463
` ` --printer` `
466
464
@@ -506,4 +504,45 @@ the following code:
506
504
507
505
Please note that as of 4.8, options can be put after the argument(s).
508
506
507
+ .. _textui.testdox:
508
+
509
+ TestDox
510
+ #######
511
+
512
+ PHPUnit' s TestDox functionality looks at a test class and all the test
513
+ method names and converts them from camel case (or snake_case) PHP names to sentences:
514
+ ``testBalanceIsInitiallyZero ()` ` (or ``test_balance_is_initially_zero ()` ` becomes " Balance is
515
+ initially zero" . If there are several test methods whose names only
516
+ differ in a suffix of one or more digits, such as
517
+ ``testBalanceCannotBecomeNegative ()` ` and
518
+ ``testBalanceCannotBecomeNegative2 ()` ` , the sentence
519
+ " Balance cannot become negative" will appear only once, assuming that
520
+ all of these tests succeed.
521
+
522
+ Let us take a look at the agile documentation generated for a
523
+ ` ` BankAccount` ` class:
524
+
525
+ .. code-block:: bash
526
+
527
+ $ phpunit --testdox BankAccountTest
528
+ PHPUnit 7.0.0 by Sebastian Bergmann and contributors.
529
+
530
+ BankAccount
531
+ ✔ Balance is initially zero
532
+ ✔ Balance cannot become negative
533
+
534
+ Alternatively, the agile documentation can be generated in HTML or plain
535
+ text format and written to a file using the ` ` --testdox-html` `
536
+ and ` ` --testdox-text` ` arguments.
537
+
538
+ Agile Documentation can be used to document the assumptions you make
539
+ about the external packages that you use in your project. When you use
540
+ an external package, you are exposed to the risks that the package will
541
+ not behave as you expect, and that future versions of the package will
542
+ change in subtle ways that will break your code, without you knowing it.
543
+ You can address these risks by writing a test every time you make an
544
+ assumption. If your test succeeds, your assumption is valid. If you
545
+ document all your assumptions with tests, future releases of the
546
+ external package will be no cause for concern: if the tests succeed,
547
+ your system should continue working.
509
548
0 commit comments