project:unittests
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
project:unittests [2025/08/03 03:31] – mnewnham | project:unittests [2025/08/05 16:54] (current) – [Prerequistes] mnewnham | ||
---|---|---|---|
Line 3: | Line 3: | ||
Unit testing can be done using PHPUnit testing. Testing can be done against any database that is available that you have admin rights on. The test creates tables, populates them with small amounts of data and drops them. | Unit testing can be done using PHPUnit testing. Testing can be done against any database that is available that you have admin rights on. The test creates tables, populates them with small amounts of data and drops them. | ||
- | ==== Prerequistes ==== | + | ===== Prerequistes ===== |
- | [[https:// | + | * PHP 8.0 or higher |
+ | | ||
===== Setup ===== | ===== Setup ===== | ||
Line 40: | Line 41: | ||
</ | </ | ||
==== Driver Section ==== | ==== Driver Section ==== | ||
- | The driver configuration is based on the driver name. | + | The driver configuration is based on the driver name. You can add as many drivers to the configuration file as you want. Only the driver specified on the command line or the first driver found in the configuration file flagged // |
< | < | ||
Line 64: | Line 65: | ||
==== Meta Section ==== | ==== Meta Section ==== | ||
- | Unless explicitly enabled, the test to create new database using the // | + | Unless explicitly enabled, the test to create |
- | < | + | < |
+ | [meta] | ||
skipDbCreation=0 | skipDbCreation=0 | ||
</ | </ | ||
Line 72: | Line 74: | ||
==== Caching Section ==== | ==== Caching Section ==== | ||
- | Unless explicitly enabled, cache functions such as // | + | Unless explicitly enabled, cache functions such as // |
+ | === Filesystem === | ||
< | < | ||
[caching] | [caching] | ||
cacheMethod=1 | cacheMethod=1 | ||
cacheDir=c:/ | cacheDir=c:/ | ||
+ | </ | ||
+ | |||
+ | === Memcache Based === | ||
+ | < | ||
+ | [cache] | ||
+ | cacheMethod=2 | ||
+ | cacheHost=192.168.1.50 | ||
</ | </ | ||
Line 93: | Line 102: | ||
===== Test Execution ===== | ===== Test Execution ===== | ||
- | ==== PHPUnit ==== | + | ==== PHPUnit |
< | < | ||
phpunit unittest --bootstrap unittest/ | phpunit unittest --bootstrap unittest/ | ||
Line 107: | Line 116: | ||
It is not possible to pass the driver name as a run-time argument in this version. The driver to test must have the **active** flag defined in the driver section. | It is not possible to pass the driver name as a run-time argument in this version. The driver to test must have the **active** flag defined in the driver section. | ||
+ | ===== Writing or Updating Tests ===== | ||
- | + | * Tests should be compliant with PHPunit version 9 and higher | |
+ | * Tests should be compatible with all platforms supported by PHPunit | ||
+ | * Tests should be written to [[https:// | ||
+ | * Wherever possible, write database agnostic tests. Only write driver specific tests when a feature is only supported by one or two DBMS | ||
+ | * Only add driver specific tests to the test file specifically labeled for that driver, e.g. // | ||
+ | * Do not add driver-based code branches inside the generic test code | ||
project/unittests.1754184675.txt.gz · Last modified: by mnewnham