Python Automated test-unittest

Source: Internet
Author: User

1. Basic Concepts

Unit test-Used to verify that there is no problem with some aspect of the function

Test Cases-a set of unit tests that verify the behavior of the function in all situations meets the requirements

Full coverage test Case-includes a complete set of unit tests that cover a variety of possible function usage patterns

2. Test function

Steps

Import UnitTest and Source functions

Create a test class that inherits from UnitTest. TestCase, and the class name starts with test

Write a test method, test the source method, and the test method should end with an assertion method

Execute the Unittest.main () method

3. Test class

Steps

Import UnitTest and source classes in the same package

Create a test class that inherits from UnitTest. TestCase, and the class name starts with test

You can write the setup (self) function, where you create the object of the source class, and you can directly "self" in each test method. Reference source object, no more new in each test method

Write a test method, test the method of the source class, and the test method should end with an assertion method

Execute the Unittest.main () method

4. Advanced Data

Selenium2+python Automation 51-unittest Introduction

Selenium2+python Automated 52-unittest execution sequence

Selenium2+python Automated 53-unittest Batch execution (Discover)

Selenium2+python Automated 54-unittest Generation Test report (Htmltestrunner)

Selenium2+python Automation 55-unittest (@classmethod)

Assertion of Selenium2+python Automation 56-unittest (Assert)

Python Automated test-unittest

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.