Acquaintance unittest

unittest description:

  unitest version of python is junit testing framework supports automated testing, test setup and shutdown code sharing, management and generate the corresponding combinations of test cases test report

unittest four functions:

test fixture

test fixture represents the preparation needed to perform one or more tests, and any associate cleanup actions. This may involve, for example, creating temporary or proxy databases, directories, or starting a server process.

  Supports one or more test components, test and clear actions, such as: temporary or create database links, directory and start the server process and other operations.

test case

test case is the smallest unit of testing. It checks for a specific response to a particular set of inputs. unittest provides a base class, TestCase, which may be used to create new test cases.

  Testing each unit test is checked in response to a specific input, the unittest provides a base class, TestCase for creating a new test.

test suite

test suite is a collection of test cases, test suites, or both. It is used to aggregate tests that should be executed together.

  A test suite is the test case, test suite, or collection of both. It is used to summarize the test should be performed together.

test runner

test runner is a component which orchestrates the execution of tests and provides the outcome to the user. The runner may use a graphical interface, a textual interface, or return a special value to indicate the results of executing the tests.

  Test Run window or interface can use the command to run a particular test case, the test returns a corresponding result

Unittest the first example:

import unittest

class TestNumMethod(unittest.TestCase):

def test_one(self):
self.assertIn(2,[1,2,3])

def test_two(self):
self.assertEqual("1",1)

if __name__ == '__main__':
unittest.main()

 

Guess you like

Origin www.cnblogs.com/qixc/p/11761186.html