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

  • 相关阅读:
    语音激活检测(VAD)--前向神经网络方法(Alex)
    语音信号处理基础
    MySQL死锁系列-插入语句正常,但是没有插入成功
    关于wx.getProfile和wx.login获取解密数据偶发失败的原因
    指针访问数组元素
    libev 源码解析
    leveldb 源码--总体架构分析
    raft--分布式一致性协议
    使用springcloud gateway搭建网关(分流,限流,熔断)
    爬虫
  • 原文地址:https://www.cnblogs.com/qixc/p/11761186.html
Copyright © 2011-2022 走看看