提示no tests were found
来源:5-1 unittest简单使用

慕的地2985539
2018-07-24
# -*- coding:utf8-*-
import unittest
class TestMethod(unittest.TestCase):
#类方法,整个测试只会执行一次,要先注解
@classmethod
def setUpClass(cls):
print '类执行之前的方法\n'
# 类方法,整个测试只会执行一次
@classmethod
def tearDownClass(cls):
print '类执行之后的方法'
#每次方法方法之前执行
def setUp(self):
print 'test-->setUp'
# 每次方法方法之后执行
def tearDown(self):
print 'test-->tearDown'
#测试方法一定要以test开头,不然无法执行
def test_01(self):
print '这个是第一个测试方法'
def test_02(self):
print '这个是第二个测试方法'
if __name__ == '__main__':
unittest.main()
2回答
-
Mushishi
2018-07-24
哈哈,这么神奇得问题你都能够遇见。那么只能说明这个你需要百度一下。哈哈。其实你在cmd下运行不会出错,只有pycharm下才出现这个错误(我曾经是),你可以把你class得名字更改一下,或者以cmd运行。
10 -
慕的地2985539
提问者
2018-07-24
已经搞定了
00
相似问题