Python unit Test (unittest)

Source: Internet
Author: User

Automation testing in the major Internet companies to roll out, then for the automation test good design ideas? ..... Today we discuss the next UnitTest data-driven (tdd:test-driven development test-driven development).

The data-driven mode of interface Automation is the mainstream design idea chosen by most companies, with data driven by MySQL, Data driven by Excel, but objectively, there is no data driven by the DDT module in the Python module which is convenient and flexible. Testers can write scripts to automate test work and interface regression testing, and developers can also perform self-test work before testing to ensure code quality.

I. Installing the DDT module

UnitTest is a python-brought module so we don't have to install it, but since DDT is not a Python standard library, we need PIP to install the DDT module (note: If the Python scripts directory has been added to the environment variable, ignore the actions below, and then directly PIP3 Install DDT installation. )

Two. Create a unittest file using Pycharm

The automatically generated files are as follows

Import unittest# generates a test class mytestcase (UnitTest. TestCase):    def test_something (self):       #结果断言                self.assertequal (True, False) if __name__ = = ' __main__ ':    Unittest.main ()

Python unit 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.