Test Database
PHPUnit can write test result and code coverage data to a Test Database. Several ideas for future features depend on this data.
Schema
- MySQL: source:phpunit/branches/release/3.2/PHPUnit/Util/Log/Database/MySQL.sql
- SQLite: source:phpunit/branches/release/3.2/PHPUnit/Util/Log/Database/SQLite3.sql
Table run
For each run of the test suite there is a row in the run table.
- Such a test run is uniquely identified by its run_id.
- A timestamp is recorded for the point in time the test run was started.
- A revision number links the sourcecode of both the code under test and the test code to a repository revision such as Subversion's Global Revision Number, for instance.
- Additional information about the test environment is optional.
- The completed flag is 1 when the test run completed and 0 otherwise (due to a fatal error, for instance).
Table test
For each test that is executed as part of a test run there is a row in the test table.
- Such a test execution is uniquely identified by its test_id.
- Information about the test is available in the test_name, test_result, test_message, and test_execution_time fields.
- The code_method_id references, if applicable, the method of a test case class that corresponds to the test.
- The node_root, node_left, and node_right fields hold the nested set information for the test hierarchy.
Table code_file
For each file that is part of a revision there is a row in the code_file table.
- Such a file is uniquely identified by its code_file_id.
- The filename is stored in the code_file_name field.
- An MD5 checksum of the file is stored in the code_file_md5 field.
- A revision number links the file to a repository revision such as Subversion's Global Revision Number, for instance.
Table code_class
For each class that is declared in a file that is part of a revision there is a row in the code_class table.
- Such a class is uniquely identified by its code_class_id.
- The code_file_id references the file (in the code_file table) that declares the class.
- The code_class_parent_id field holds a reference to the parent class.
- The name of the class is stored in the code_class_name field.
- The code_class_start_line and code_class_end_line fields mark the lines of code in the file that make up the class.
Table code_method
For each method that is declared in a file that is part of a revision there is a row in the code_method table.
- Such a method is uniquely identified by its code_method_id.
- The code_class_id references the class (in the code_class table) to which the method belongs.
- The name of the method is stored in the code_method_name field.
- The code_method_start_line and code_method_end_line fields mark the lines of code in the file that make up the method.
Table code_line
For each line of code that belongs to a file that is part of a revision there is a row in the code_line table.
- Such a line of code is uniquely identified by its code_line_id.
- The code_file_id references the file (in the code_file table) to which the line belongs.
- The code_line_number field holds the number of the line of code in the file.
- The code_line field holds the line of code.
- The code_line_covered field holds a code coverage status flag:
- 1: Line is executable and has been executed by at least one test.
- 0: Line is not executable.
- -1: Line is executable but has not been executed.
- -2: Line is dead code.
Table code_coverage
The code_coverage table connects each test (test_id) to the lines of code (code_line_id) it covers.
Sample Database
BankAccount.sql is an SQLite dump of a test database for the BankAccount (phpunit/branches/3.2/PHPUnit/Samples/BankAccount) example. It contains two test runs of BankAccountTest. The one at revision 1 is without and the one at revision 2 is with the testDepositWithdrawMoney() test.
Attachments
-
BankAccount.sql
(27.6 KB) - added by sb
2 years ago.
SQLite dump of a test database for the BankAccount example.
