[TYPO3-core] RFC #10220: Feature: Get some unit tests for the core

Ernesto Baschny [cron IT] ernst at cron-it.de
Fri Jan 23 10:24:54 CET 2009


Oliver Klee wrote: on 22.01.2009 19:06:
> Hi Dmitry,
> 
> Dmitry Dulepov schrieb:
>> What I enjoyed/disliked (50/50) in the patch is this function name:
>>
>> testCheckModifyAccessListForNonAdminWithTableModifyAccessForBeUsersTableReturnsFalse()
>>
>> Reminds me one of my favorite web sites:
>> http://www.millionreasonswhylatviaisthebestcountryintheworld.com/
> 
> Hehe ... ;-)
> 
> Yes, that's the problem of fitting the following things in one function
> name:
> 
> 1. "test" (required for the function to be recognized as a test function)
> 2. the name of the tested functions
> 3. any relevant (pre-)conditions
> 4. the expected result
> 
> The simpler a function, the shorter the test name because:
> 1. simpler functions (ie. functions that do only one thing) can have
> shorter names
> 2. the conditions and results are simpler
> 
> In my projects, we've defined test function names as an exception of the
> 80-characters rule-of-thumb because of this.

I don't really see the need to have that much information in the test
names function. If some test "failed", you will have to look at the test
function anyway, to see what was wrong.

Even better is to document the test cases (phpdoc) so that one knows
what is being tested. It is very ugly to have all information inside the
difficult-to-read function name.

And maybe split-up test cases in different classes, because I can
imagine that testing "TCEmain" will be a LOT larger with time. Splitting
it up migth also help in getting shorter test function names.

Some ideas for more "speaking names". Instead of:

t3lib_tcemain_testcase:

testCheckModifyAccessListForNonAdminWithTableModifyAccessForContentTableReturnsTrue()

Something like this:

t3lib_tcemain_accesscontrol_testcase:
  testNonAdminCannotModifyAdminTable()

And instead of:

t3lib_tcemain_testcase:

testCheckModifyAccessListForNonAdminWithTableModifyAccessForContentTableReturnsTrue()

How about:

t3lib_tcemain_accesscontrol_testcase:
  testNonAdminCanModifyAllowedTable()


Cheers,
Ernesto


More information about the TYPO3-team-core mailing list