[TYPO3-dev] Funcitonal tests examples
Viktor Livakivskyi
invisible.kinder at gmail.com
Mon Nov 16 20:19:23 CET 2015
Hi, list
I've decided to extend my knowledge of automatized testings with TYPO3.
So far I was writing only unit tests, which is now quite easy for me:
- mock everything
- give some food to your SUT
- check what it gives you back or what it calls
- profit
But now I decided to go one step forward and try functional tests.
My SUT is Controller and cases I want to test:
1. overviewAction() lists objects, created only by current user;
2. initializeAction() redirects to a startAction(), when current action requires an argument to be provided, but it is missing in request (such thing happens on multi-step forms, when someone tries to GET 2nd or later step of a form)
3. saveAction() creates an entity in db, including child objects (so, propertyMapping configuration will be tested as well) and internally request to a REST api is made
>From my understanding the process is:
- do not mock anything (or almost anything)
- provide XML fixtures
- provide extensions, code depends on
- provide TS, needed for code to run
- provide a lot of other stuff...
- give some input to SUT
- check if it does what you want: created entry in db, output the expected content, etc.
- profit
For an inspiration I took a look at core tests. F.e. extbase\Tests\Functional\Persistence\AddTest.php - is quite easy to understand.
With extbase\Tests\Functional\Persistence\EnableFieldsTest.php it is a bit harder, because of ->getResponseSections('Extbase:list()'), which as I understand, gets some structured output of action "list()" from, plugin "Blogs", as configured in JsonRenderer.ts.
So, my questions are:
1. Are there any tutorials with examples for TYPO3 functional testing?
2. Is there a way to simulate FE GET or POST request to run code in my controller or it is not in a concpet of functional testing?
3. Is it possible to check, that during code execution a request to REST service was made without injecting RestClient stub into specific class?
4. What are these response "sections"?
More information about the TYPO3-dev
mailing list