[TYPO3-core] Contribution to TYPO3 v4 :: PHP unit tests (before pushing to gerrit)

Christian Kuhn lolli at schwarzbu.ch
Thu Jun 14 20:38:52 CEST 2012


Hey,

On 06/12/2012 02:38 PM, Roland wrote:
> i commited some CGL violation patches lately and would like to start
> unit testing the core before i push my commit to gerrit.

Thanks for all your CGL work!


> what is the best way to do this?
>
> --- quote ---
> 696 tests, 814 assertions, 11 failures, 31 skipped, 1 not implemented, 1
> errors, 12.565 seconds, 23 MB (23913832 B) memory leaks
> --- /quote ---

current master:
1721 tests, 2321 assertions, 1 failures, 77 skipped, 0 not implemented, 
0 errors, 48.49 seconds, 59 MB (61832584 B) memory leaks

The failing test is 'filenamesAreCorrectlyValidated', I didn't had time 
to track it down, yet. I've fixed all other failing tests that where in 
master for me some weeks ago.

In general, ext:phpunit is the way to go: Either via the backend module, 
or through cli_dispatch.php


> there seems to exist tests which do not pass. is this ok? if so: does
> unit testing make sense before pushing to gerrit?

Yes. Tests are usually pushed together with the rest of the patch. If 
you really fix a bug and write a test for it, you could mention in a 
comment that the test fails without the code change, and works if the 
fix part is applied.


> i went to ci.typo3.org and searched for phpunit test results? does
> jenkins execute the unit tests for TYPO3 v4 at the moment?

Unfortunatly not, yet. I'm still hoping that we finally get this at some 
point in the future. As far as I know, the basic problem is, that 
jenkins must set up a full typo3 environment with db for each run and 
must keep that up to date.

Furthermore, I personally do not really like that tests are not packaged 
and not included in the downloads, but only in git.


> what about unit tests? aren't they important? i guess the are
> obligatorly run by the core team member which merges the commit into core?

I keep a close eye on them, but you are right it would be much better if 
jenkins would -1 a patch if more tests fail after the change is applied.


> is there something about this toppic in the wiki? i could not find it.

How to write tests can be currently best learned by reading through the 
existing tests. There are also examples for nifty things. The fact that 
patches with unit tests are preferred (especially if they are bugfixes 
that are ported to stable branches) is currently underdocumented in the 
wiki and we should work on that. All in all documentation for both 'unit 
tests for the core' and 'jenkins/metrics and how to work with it' are 
heavily underdocumentated ... help highly appreciated. If you wanna work 
in this area we could kickoff together!


Regards
Christian


More information about the TYPO3-team-core mailing list