日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python unit test_python 中unittest单元测试为什么addTest没用。

發(fā)布時間:2023/12/19 python 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python unit test_python 中unittest单元测试为什么addTest没用。 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

#!?/usr/bin/env?python

#!?-*-cording:utf-8?-*-

import?unittest

from?appium?import?webdriver

import?time

#腳本初始化獲取操作實例

class?MyTestCase(unittest.TestCase):

def?setUp(self):

desired_caps={}

desired_caps['platformName']='Android'

desired_caps['platformVersion']='7.1.1'

desired_caps['deviceName']='Galaxy?Note8'

desired_caps['appPackage']='com.sec.android.app.popupcalculator'

desired_caps['appActivity']='.Calculator?'

desired_caps['unicodeKeyboard']='True'

desired_caps['resetKeyboard']='False'

self.driver=webdriver.Remote("http://localhost:4723/wd/hub",desired_caps)

def?tearDown(self):

self.driver.quit()

def?testAdd(self):

number8=self.driver.find_element_by_id("bt_08")

number8.click()

numberadd=self.driver.find_element_by_id("bt_add")

numberadd.click()

number5=self.driver.find_element_by_id("bt_05")

number5.click()

equal=self.driver.find_element_by_id("bt_equal")

equal.click()

try:

result=self.driver.find_element_by_id('txtCalc')

value=result.text

self.assertEqual(u"13",value)

except?Exception:

print?("程序出現(xiàn)異常了")

self.fail("程序出現(xiàn)異常")

def?testmoreAPI(self):

self.driver.flick(100,750,100,100)

print(self.driver.wait_activity('.Calculator',3,1))

time.sleep(5)

def?get_suite(self):

if?__name__?==?'__main__':

suite?=?unittest.TestSuite()

suite.addTests(MyTestCase('testmoreAPI'))

runner=unittest.TextTestRunner(verbosity=2)

runner.run(suit)

初學python的unittest部分 ,如果我只想執(zhí)行testmoreAPI測試方法,這種寫法可以嗎?為什么執(zhí)行的時候,還是從testAdd開始執(zhí)行了?【不需要執(zhí)行testAdd】

總結

以上是生活随笔為你收集整理的python unit test_python 中unittest单元测试为什么addTest没用。的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。