Rename test methods, add @test annotation, extend base class
PHPUnit supports annotations for some time now. Therefore we should remove the "test_" prefix from all test methods and mark the method with a @test annotation instead.
Additionally, test cases should now extend the T3_Testing_BaseTestCase instead of PHPUnit_Framework_TestCase.
Finally, the require_once() for the PHPUnit Base Class is not needed anymore and should be removed.
All this also needs to be documented in the Coding Guidelines.
#1 Updated by Robert Lemke about 12 years ago
(In r402) Speed for Unit Tests!
- All unit tests now extend the new T3_Testing_BaseTestCase instead of PHPUnit_Framework_TestCase. Addresses #76.
- CMS: Cleaned up setUp() method - now the componentManager instance is reused. Speed gain: 5833% on my machine! Addresses #76
- Framework: Refactored all unit tests to reuse the componentManager. Full run on my machine before: 4'59", after 0'13". Speed gain: 2300%. Addresses #76
- Framework: Various small bug fixes (including new tests of course) which appeared while refactoring the tests.
#5 Updated by Tim Eilers about 12 years ago
Should i also create a sniff for the coding guidelines validator which is under development at the moment?
It makes no sense to check all methods for a test tag in a Test Class, since you sometimes want to deactivate some tests for some reasons, but perhaps i could check if a method begins with test_ if it is in a test class.
I also could check if PHPUnit_Framework_TestCase to give out a warning.
What is your opinion?
#6 Updated by Robert Lemke about 12 years ago
If you like you can create a sniff for the following rule:
"Names of methods of classes which are located in files which reside in the Tests/ directory of a package must not start with 'test'".
But that's really low priority - at least from my side.