import unittest #1匯入unittest測試包#2建立測試類並繼承unittest
class testcase(unittest.testcase):
#3定義初始化搭建方法
def setup(self):
print("初始化")
#4執行測試用例過程
def test_mydemo(self):
print("請輸入用例資料")
self.assertequal(0,1,"臥槽")
print("執行完成")
#5清空環境銷毀
def teardown(self):
print("清空環境")
#通過main 載入該用例
if __name__ == '__main__':
unittest.main()
import unittest#執行測試用例集合
#測試集合1
class tests1(unittest.testcase):
def testc1(self):
print("this is one")
def testc2(self):
print("this is two")
#測試集合2
class tests2(unittest.testcase):
def testc1(self):
print("this is three")
def testc2(self):
print("this is four")
#啟動if __name__ == '__main__':
#載入su1=unittest.defaulttestloader.loadtestsfromtestcase(tests1)
su2=unittest.defaulttestloader.loadtestsfromtestcase(tests2)
# unittest.testloader.loadtestsfromtestcase()
#新增m = unittest.testsuite.addtest(su1)
m = unittest.testsuite.addtest(su2)
App自動化測試之unittest入門
import unittest class teststringmethods unittest.testcase def test upper self self.assertequal foo upper foo def test isupper self self.asserttrue foo...
python自動化測試unittest的使用
import unittest class testlogin unittest.testcase def test 01 self b 1 斷言相等 self.assertequal b,2 def test 02 self b 23 斷言是否b是不是 1234 的子串 self.asserteq...
介面自動化之unittest初探
usr bin python3 coding utf 8 time 2018 12 7 11 03 author yosef 夜雨聲煩 email wurz529 foxmail.com file model.py software pycharm community edition unittes...