1
0
mirror of synced 2025-02-12 02:09:24 +03:00

41 lines
2.1 KiB
Plaintext

+++ Running tests
Tests can be run either in a browser via the url DOCTRINE_PATH/tests/run.php or
on the command line.
On the command line navigate to the DOCTRINE_PATH/tests folder and run
<code type="bash">
php run.php
</code>
On the command line the testing script has several options.
* in order to generate coverage report run the script with the -coverage flag.
* in order to run just a subselect of tests use the -group flag.
* in order to filter the tests aginst a custom string use the -filter flag.
* for more information run the script with the -help flag.
+++ Writing tests
++++ Classes
* All test classes should be referring to a class or specific testing aspect of some class.
* For example {{Doctrine_Record_TestCase}} is a valid name since its referring to class named {{Doctrine_Record}}.
* {{Doctrine_Record_State_TestCase}} is also a valid name since its referring to testing the state aspect of the {{Doctrine_Record}} class.
* However something like {{Doctrine_PrimaryKey_TestCase}} is not valid since its way too generic.
* Every class should have atleast one {{TestCase}} equivalent
* All testcase classes should inherit {{Doctrine_UnitTestCase}}
++++ Methods
* All methods should support agile documentation; if some method failed it should be evident from the name of the test method what went wrong. Also the test method names should give information of the system they test.
* For example {{Doctrine_Export_Pgsql_TestCase::testCreateTableSupportsAutoincPks()}} is a valid test method name. Just by looking at it we know what it is testing. Also we can run agile documentation tool to get little up-to-date system information.
NOTE: Commonly used testing method naming convention {{TestCase::test[methodName]}} is **not** allowed in Doctrine. So in this case {{Doctrine_Export_Pgsql_TestCase::testCreateTable()}} would not be allowed!
* Test method names can often be long. However the content within the methods should rarely be more than dozen lines long. If you need several assert-calls divide the method into smaller methods.
++++ Assertions
* There should never be assertions within any loops and rarely within functions.