Getting started with unit test SimpleTest and getting started with simpletest

Source: Internet
Author: User

Getting started with unit test SimpleTest and getting started with simpletest

Recently, I used PHPunit to test the learning unit test. As a result, there were a lot of installation problems, so I immediately gave up and tried simpletest. It was much simpler. 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. Put the folder in the root directory of your project.

3. Write the file to be tested, Sum. php, a simple Sum class, which is stored in the project root directory.

 

4. Write the test file testSum. php to the root directory of the project.

We can see that there are 2 test classes and 5 test projects, of which 2 test results do not meet our expectations. during the test, you can directly execute the file without instantiating test classes 1 and 2. the result is as follows:

2/2 indicates that there are two test classes. The result is 3 passed and 2 errors. The error causes are listed.

Let's modify the code to get rid of the wrong input:

Result:

Test passed!

 

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

5. Read the English document

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.