zoukankan      html  css  js  c++  java
  • 初识unittest

    unittest介绍:

      unitest是python版本的junit测试框架,支持测试自动化、共享测试设置和关闭代码,测试用例组合管理及生成对应的测试报告

    unittest四大功能:

    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.

      支持一个或多个的测试组件,以及清除测试动作,例如:创建或临时数据库链接,目录及启动服务器进程等操作。

    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.

      测试用例是测试的各个单元,检查了一个特定输入的响应,unittest提供了一个基类,TestCase用于创建新的测试用例。

    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.

      一个测试套件是测试案例,测试套件,或两者的集合。它用于汇总应一起执行的测试。

    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.

      测试运行可以使用命令窗口或者界面运行特定的测试用例,返回对应的测试结果

    unittest的第一个例子:

    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()

  • 相关阅读:
    如何在域和域之间建立信任域?关键是配置域和域之间的DNS服务器
    Client Recevier 命令安装 AllUsers=1
    在XD 4.0 设置Policy
    更改linux系统中键盘设置
    如何在DNS中添加另一DNS
    CMD命令
    KMS激活OS(系统)
    谁抢了我的IP!!!~
    关于域证书的发布CA和CRL的内容 (Windows 2008 Server R2 SP1)
    XenServer假死状态
  • 原文地址:https://www.cnblogs.com/qixc/p/11761186.html
Copyright © 2011-2022 走看看