SimpleTest is a very simple unit testing tool.
I designed it myself. Code that uses SimpleTest to unit test a project
I. Structure of documents
A project has multiple folders, and folders also contain folders. The code that we want to test is included in these folders. To do unit testing, I think there are three kinds of:
When a programmer is developing a function, method, etc., it is tested while the development is complete or even during development. Test cases may be written while developing, or written at the detailed design stage of the project;
Perform some centralized testing of all function points in a module (including multiple function points) to check whether every function point can pass the test;
Uniform unit tests for the entire project. Usually combined with the daily construct.
For the above three scenarios, the test code that I designed contains the following folders and files:
1 in the root directory of the project folder, place a Unit_test folder containing setup.inc.php and index.php
setup.inc.php |
Test the initialization file of the system, and each test program that executes directly contains it |
index.php |
Procedures for the overall testing of the system |
2 in each subfolder that requires unit testing, establish a Unit_test folder that contains a index.php and several files with the same name as the unit test function point. For example, for one of the following fruits modules (located in the project's Fruits folder), the structure is as follows:
Folder structure |
File description |
Fruits |
folder for Fruits modules |
CFruits.class.php |
The base class of fruit |
CApple.class.php |
Apple class |
CBanana.class.php |
Banana class |
Unit_test |
Unit Test Folder |
index.php |
The program that tests the fruits module centrally |
CFruits.class.php |
Code for unit testing of CFruits.class.php in a fruits module |
CApple.class.php |
Code for unit testing of CApple.class.php in a fruits module |
CBanana.class.php |
Code for unit testing of CBanana.class.php in a fruits module |