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)