#! /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 ("程序出现异常了") self.fail("程序出现异常") 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部分 ,如果我只想执行testmoreAPI测试方法,这种写法可以吗?为什么执行的时候,还是从testAdd开始执行了?【不需要执行testAdd】
慕运维539141