TA的每日心情 | 擦汗 8 小时前 |
---|
签到天数: 527 天 连续签到: 4 天 [LV.9]测试副司令
|
1测试积点
问题:
unittest 使用 discover 加载用例,运行结果为空
我的代码如下图所示:
- <font face="微软雅黑" size="3">import unittest,os
- case_path=os.path.join(os.getcwd(),"test_login")
- suite=unittest.defaultTestLoader.discover(case_path,pattern="test_*.py")
- print(suite)
- if __name__=='__main__':
- runner=unittest.TextTestRunner()
- runner.run(suite)
- #unittest.main(defaultTest='suite',verbosity=2)</font>
复制代码
运行结果如下:
- <font face="微软雅黑" size="3">
- Launching unittests with arguments python -m unittest E:/Testcmmcar-2.0/src/script/login/testrunner.py in E:\Testcmmcar-2.0\src\script\login
- Ran 0 tests in 0.000s
- OK
- <unittest.suite.TestSuite tests=[<unittest.suite.TestSuite tests=[<unittest.suite.TestSuite tests=[<test_login_failure.test_login_failure testMethod=test_no_authority>, <test_login_failure.test_login_failure testMethod=test_password_error>, <test_login_failure.test_login_failure testMethod=test_password_null>, <test_login_failure.test_login_failure testMethod=test_username_error>, <test_login_failure.test_login_failure testMethod=test_username_null>]>]>, <unittest.suite.TestSuite tests=[<unittest.suite.TestSuite tests=[<test_login_success.test_login_success testMethod=test_login>]>]>, <unittest.suite.TestSuite tests=[<unittest.suite.TestSuite tests=[<test_logout.test_logout testMethod=test_logout>]>]>]>
- Process finished with exit code 0
- Empty test suite.
- </font>
复制代码
输出suite,不是已经证明我的测试套件中是有用例的吗!为什么运行结果显示为空呢?
|
|