Using SimpleTest in PHP for unit testing

Source: Internet
Author: User
Tags php and root directory

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.