From d273405235bc6eb39640b3236e17ac32d24633c2 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Sun, 24 Jun 2018 20:24:46 +0200 Subject: [PATCH] TASK: Add further output formats --- .gitignore | 1 + readme.rst | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 43c01d7..14eb692 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ vendor index.php typo3 /Tests +/Results diff --git a/readme.rst b/readme.rst index 4453fcc..1177024 100644 --- a/readme.rst +++ b/readme.rst @@ -34,19 +34,41 @@ Links: Create first test ----------------- -We want to test the model first:: +Hands on! Let's write a first basic test. + +E.g. a small model with a bit logic:: mkdir -p Tests/Unit/Domain/Model cp Resources/Private/CodeExamples/Tests/Unit/Domain/Model/AddressTest.php \ Tests/Unit/Domain/Model/AddressTest.php -Execute first test:: +Execute the first test:: ./vendor/bin/phpunit Tests/Unit/ +What's in the test? +------------------- + +#. We have one PHP class `AddressTest`. + +#. Two public methods. + +#. The methods are annotated with `@test`. + +#. Methods create an instance of the class to test. + +#. Methods call an `assert*()` method. + Create test for controller -------------------------- +Introduction to mocking +^^^^^^^^^^^^^^^^^^^^^^^ + + +Add the test +^^^^^^^^^^^^ + We want to test the controller now:: mkdir -p Tests/Unit/Controller @@ -56,3 +78,26 @@ We want to test the controller now:: Execute all tests:: ./vendor/bin/phpunit Tests/Unit/ + +Alternative output +------------------ + +testdox + Used as "agile" output:: + + ./vendor/bin/phpunit Tests/Unit/ --testdox-html Results/testdox.html + xdg-open Results/testdox.html + +xml + Used in CI to parse results:: + + ./vendor/bin/phpunit --log-junit Results/junit.xml Tests/Unit + +html Coverage + Used to check which methods still need testing:: + + ./vendor/bin/phpunit --coverage-html Results/Coverage/ --whitelist Classes Tests/Unit + xdg-open Results/Coverage/index.html + +Benefits of tests +-----------------