产品与解决方案 加急 Pycharm 提示 Empty test suite. case 一个都没跑

丧尸没有牙齿 · 2017年06月13日 · 最后由 arkin 回复于 2017年06月14日 · 3827 次阅读
# urs/bin/python
# encoding:utf-8
import time
from appium import webdriver
import unittest


class MyTestCase(unittest.TestCase):
    def setUp(self):
        self.desired_caps = {}
        self.desired_caps['platformName'] = 'Android'
        self.desired_caps['platformVersion'] = '7.0'
        self.desired_caps['deviceName'] = '8223d2ed'
        self.desired_caps['appPackage'] = 'com.doro'
        self.desired_caps['appActivity'] = '.MainActivity '
        self.desired_caps["unicodeKeyboard"] = "True"
        self.desired_caps["resetKeyboard"] = "True"
        self.desired_caps['automationName'] = 'Uiautomator2'
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', self.desired_caps)

    def cameraCase(self):
        time.sleep(1)
        self.driver.press_keycode(3)
        time.sleep(1)
        self.driver.tap([(359, 1247)])
        time.sleep(1)
        self.driver.tap([(359, 1247)])
        time.sleep(2)
        input = self.driver.find_element_by_id("com.doro.apps.launcher3:id/search_box_input")
        input.send_keys("Ca")
        time.sleep(1)
        # self.driver.find_element_by_xpath("//android.widget.FrameLayout[contains(@content-desc ,'Camera')]").click()
        self.driver.tap([(550, 500)])
        self.driver.find_element_by_id("com.mediatek.camera:id/shutter_button_photo")
        time.sleep(1)
        self.driver.find_element_by_id("com.mediatek.camera:id/thumbnail").click()
        time.sleep(1)
        self.driver.get_screenshot_as_file("Camera shut.png")

    def wifiCase(self):
        self.driver.press_keycode(3)
        time.sleep(1)
        self.driver.flick(360, 0, 360, 1000)
        time.sleep(1)
        self.driver.tap([(550, 500)], 2)
        self.driver.find_element_by_id("com.android.settings:id/switch_widget")
        self.driver.find_elements_by_xpath("//android.widget.FrameLayout [contains(@content-desc,'CKT,,Wifi signal full')]").click()
        password = self.driver.find_element_by_id("com.android.settings:id/password")
        password.send_keys("ck88888!")
        self.driver.find_element_by_id("android:id/button1").click()

    def tearDown(self):
            self.driver.quit()

if __name__ == '__main__':
    unittest.main()
![](/uploads/photo/2017/b66d5ad3-2a0b-4ed6-a512-1d3210fac116.jpg!large)

能看出是哪里出问题了吗?

共收到 5 条回复 时间 点赞

用例用 test 开头,如 testWifiCase

用了也不行的

This naming convention informs the test runner about which methods represent tests.

python 自带的 unittest 默认执行以 test 开头的方法

https://docs.python.org/2/library/unittest.html#basic-example

@Lihuazhang
这个帖子出现在首页了 0.0

报错:‘空的测试套件 ‘’,执行函数命名:"test_cameraCase " ; Pycharm 下文件夹、文件、类、函数名称,不能重复; 执行函数名 test_

Pycharm 对命名检查很严格;

丧尸没有牙齿 关闭了讨论 06月14日 09:42
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册