Python Unit Test UnitTest framework

Source: Internet
Author: User

Environment: Pycharm 2016.2 + python 3.5

Classes to be tested: (widget.py)

Test class: (auto.py)

Test results:

Summarize:
1. First step: Write the test class first.
2. The second step: Import unittest modules and test classes, using the Setup () method to do pre-test preparation, such as the establishment of database connection, the use of teardown () method to do the cleanup after testing, such as the elimination of database links, and then the method of the class to do a test.
3. Step three: Write the global Approach to the suite () and add the methods that will be tested.
Test results, there are several test cases there are several. The last display is OK, which means pass.

Python Unit Test UnitTest framework

Related Article

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.