zoukankan      html  css  js  c++  java
  • appium+python自动化项目实战(一):引入nose和allure框架

    本文将介绍一套比较完整的appium自动化框架,以python为编写脚本语言,是因为python有强大的库,同时易学易懂。

    最终的测试框架代码,将在jenkins项目中一键构建,执行自动化测试用例,并输出展现形式丰富的测试报告。

    appium及python的环境,自行安装和配置,本人使用pycharam进行自动化开发。

    一、安装nose及依赖库

    • pip install nose
    • pip install nose-allure-plugin
    • pip install nose-html-reporting
    • pip install nose-ittr
    • pip install nosehtmlouput-2

    二、安装allure及依赖库

    • pip install allure-behave
    • pip install allure-python-commons

    三、编写测试用例

    import unittest
    import nose
    from nose.tools import *
    import logging
    from page.common.tab_bar_page import TabBarPage
    from page.video.video_tab_bar_page import VideoTabBarPage
    from common.common_operate import *
    
    
    class TestVideoTabBar(unittest.TestCase):
        log = logging.getLogger(__name__)
    
        @classmethod
        def setUpClass(cls):
            cls.tab_bar = TabBarPage()
            cls.tab_bar.click_vedio_tab_bar()
            cls.video_tab_bar = VideoTabBarPage()
    
        def setUp(cls):
            pass
    
        # 点击视频文章标题
        @nose.allure.feature('视频Tab')
        @nose.allure.story('点击标题-查看视频文章')
        def test_01_click_video_title(self):
            try:
                self.video_tab_bar.click_video_title(0)
                assert_true(is_visibility(self.video_tab_bar.video_article_comments_btn_loc))
            except TimeoutException as e:
                take_screenShot(u"点击标题-查看视频文章'")
                logging.error(e)
                assert_false(True)
    
        # 点击视频预览图
        @nose.allure.feature('视频Tab')
        @nose.allure.story('点击视频预览图-查看视频文章')
        def test_02_video_preview(self):
            try:
                self.video_tab_bar.click_video_preview(0)
                assert_true(is_visibility(self.video_tab_bar.video_article_list_comments_btn_loc))
            except TimeoutException as e:
                take_screenShot(u"点击视频预览图-查看视频文章'")
                logging.error(e)
                assert_false(True)
    
        def tearDown(cls):
            get_press_keycode(4)
    
        @classmethod
        def tearDownClass(cls):
            time.sleep(3)
            get_press_keycode(4)

    这里先贴一下测试用例脚本,后面会介绍自动化项目代码、设计、运行原理等。

  • 相关阅读:
    接口新建学习---边界提取器
    Android Studio打包.so文件教程
    想要开发好的软件,必须学会这几项!
    你应该首先保护哪些应用程序?这个问题本身问错了!
    几周内搞定Java的10个方法
    翻译:程序员做些业余项目的重要性
    【源码】c#编写的安卓客户端与Windows服务器程序进行网络通信
    10款GitHub上最火爆的国产开源项目
    你的Android应用完全不需要那么多的权限
    2015年移动领域发展的九大趋势
  • 原文地址:https://www.cnblogs.com/luihengk/p/11413940.html
Copyright © 2011-2022 走看看