search
Homephp教程php手册Getting Started with Unit Testing SimpleTest

I recently learned about unit testing. I first used PHPunit, but there were a lot of installation problems, so I immediately gave up and tried simpletest. It felt much easier. The steps are listed below.

1. Download simpletest (version 1.1.0), http://www.winsite.com/Development/Miscellaneous/SimpleTest/

Get a folder named simpletest

2. Place the folder in the root directory of your project.

3. Write the file to be tested, Sum.php, a simple sum class, and put it in the project root directory

4. Write the test file, testSum.php, and put it in the project root directory

We can see that there are 2 test classes and 5 test projects, and the test results of 2 of them are not in line with our expectations. When executing the test, there is no need to instantiate test classes 1 and 2, just execute the file directly .The results are as follows:

2/2 means there are 2 test classes; the results are 3 passed and 2 errors; the error reasons have been listed.

Let’s modify the code and correct the incorrect input:

The result is:

Test passed!

4. The above is just a simple example, the actual test must be much more complicated. Next is to read the document: https://pan.baidu.com/s/1nv0HOZv

5. Read the English documentation

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use