[TYPO3-dev] Unit and functional tests for extensions with 7.4
Helmut Hummel
helmut.hummel at typo3.org
Sun Sep 6 18:52:26 CEST 2015
Hi Nico!
Nicolas de Haen wrote:
> I'm just trying to get the Unit and Functional tests of an updated
> version of the ExtensionBuilder to work on 7.4, but get weird problems:
Inspired by your question, I created an example extension and wrote a
blog post about that topic:
http://insight.helhum.io/post/128489463110/testing-your-typo3-extensions-on-travis-ci
> 1st approach: I added a UnitTests.xml including the
> sysext/core/Build/UnitTestsBootstrap.php and extend the
> \TYPO3\CMS\Core\Tests\UnitTestCase
This shouldn't be necessary.
> First fatal error: class \EBT\ExtensionBuilder\Tests\BaseTest not found
The class loading issue should be tackled when following my tutorial.
> If I include it manually all classes are loaded but the result is
> another fatal error: Call to a member function exec_SELECTgetSingleRow()
> on null in
> /var/www/typo3_src-7.4.git/typo3/sysext/core/Classes/Cache/Backend/Typo3DatabaseBackend.php
> on line 169
> The backtrace shows, that the ClassInfoCache uses the Typo3DBCache as
> backend, although I configured the extbase_object Cache backend to use
> the TYPO3\CMS\Core\Cache\Backend\NullBackend (and all other cache types)
This looks like incomplete mocking.
Where do you configure that? When executing unit tests only a very
limited TYPO3 bootstrap is executed, basically only that classes are
loaded. This means your tests must not call other TYPO3 API and of
course do not make database connections.
> 2nd approach: I use the sysext/core/Build/FunctionalTestsBootstrap.php
> and extend the \TYPO3\CMS\Core\Tests\FunctionalTestCase - besides the
> same autoloading error as above
Should also work when you follow my tutorial.
If you need a DB connection in your tests, or a more complete TYPO3
setup, functional tests are your indeed friend.
HTH
Kind regards,
Helmut
--
Helmut Hummel
Release Manager TYPO3 6.0
TYPO3 CMS Active Contributor, TYPO3 Security Team Member
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the TYPO3-dev
mailing list