Home php教程 php手册 Getting Started with Unit Testing SimpleTest

Getting Started with Unit Testing SimpleTest

Sep 09, 2016 am 08:13 AM

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 of this Website
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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1663
14
PHP Tutorial
1264
29
C# Tutorial
1237
24