说明:该篇博客是博主一字一码编写的,实属不易,请尊重原创,谢谢大家!
四丶Unittest介绍及项目实战中的运用
1.unittest介绍及运用
- 在case包下创建一个unittest_case模块,编写如下代码,在继承unittest模块的TestCase类时,需要定义以test开头的方法才能在运行unittest测试代码时被调用执行
# -*- coding: utf-8 -*-
__author__ = 'cdtaogang'
__date__ = '2019/7/3 18:48'
import unittest
class FirstCase_02(unittest.TestCase):
def test_01(self):
print("test_01")
def test_02(self):
print("test_02")
def say_hello(self):
print("say_hello")
if __name__ == '__main__':
unittest.main()
- 运行以上代码,结果已说明一切,只调用了以test开头的方法
查看内容:******** [隐藏内容购买后可见]
评论前必须登录!
注册