TASK: Add further output formats

This commit is contained in:
Daniel Siepmann 2018-06-24 20:24:46 +02:00
parent 47602a5e0b
commit d273405235
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
2 changed files with 48 additions and 2 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@ vendor
index.php index.php
typo3 typo3
/Tests /Tests
/Results

View file

@ -34,19 +34,41 @@ Links:
Create first test 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 mkdir -p Tests/Unit/Domain/Model
cp Resources/Private/CodeExamples/Tests/Unit/Domain/Model/AddressTest.php \ cp Resources/Private/CodeExamples/Tests/Unit/Domain/Model/AddressTest.php \
Tests/Unit/Domain/Model/AddressTest.php Tests/Unit/Domain/Model/AddressTest.php
Execute first test:: Execute the first test::
./vendor/bin/phpunit Tests/Unit/ ./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 Create test for controller
-------------------------- --------------------------
Introduction to mocking
^^^^^^^^^^^^^^^^^^^^^^^
Add the test
^^^^^^^^^^^^
We want to test the controller now:: We want to test the controller now::
mkdir -p Tests/Unit/Controller mkdir -p Tests/Unit/Controller
@ -56,3 +78,26 @@ We want to test the controller now::
Execute all tests:: Execute all tests::
./vendor/bin/phpunit Tests/Unit/ ./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
-----------------