GithubHelp home page GithubHelp logo

pocounit's Introduction

PocoUnit (unittest framework for poco)

pocounit

如需构建自动化工程项目,请直接使用 my-testflow

可配合airtest和poco使用的单元测试框架。规范了脚本编写的格式,提供流式日志(stream log)记录服务,然后可以使用 PocoResultPlayer 将运行的内容回放。

Installation

pip install pocounit

用法

首先需要继承基类PocoTestCase实现项目组自己的MyBaseTestCase,在MyBaseTestCase预处理中将需要用到的对象准备好(包括实例化hunter和poco和动作捕捉),以后在其余用例中继承MyBaseTestCase即可。

基本用法可参考一下代码模板。

# coding=utf-8

from pocounit.case import PocoTestCase
from pocounit.addons.poco.action_tracking import ActionTracker

from poco.drivers.unity3d import UnityPoco


class MyBaseTestCase(PocoTestCase):
    @classmethod
    def setUpClass(cls):
        super(MyBaseTestCase, cls).setUpClass()
        cls.poco = UnityPoco()

        # 启用动作捕捉(action tracker)
        action_tracker = ActionTracker(cls.poco)
        cls.register_addon(action_tracker)

然后可以开始编写自己的testcase

# coding=utf8

from ... import MyBaseTestCase


# 一个文件里建议就只有一个TestCase
# 一个Case做的事情尽量简单,不要把一大串操作都放到一起
class MyTestCase(MyBaseTestCase):
    def setUp(self):
        # 可以调用一些前置条件指令和预处理指令
        pass

    # 函数名就是这个,用其他名字无效
    def runTest(self):
        # 普通语句跟原来一样
        self.poco(text='角色').click()

        # 断言语句跟python unittest写法一模一样
        self.assertTrue(self.poco(text='最大生命').wait(3).exists(), "看到了最大生命")

        self.poco('btn_close').click()
        self.poco('movetouch_panel').offspring('point_img').swipe('up')

    def tearDown(self):
        # 如果没有清场操作,这个函数就不用写出来
        pass

    # 不要写以test开头的函数,除非你知道会发生什么
    # def test_xxx():
    #     pass


if __name__ in '__main__':
    import pocounit
    pocounit.main()

pocounit's People

Contributors

adolli avatar

Watchers

James Cloos avatar leizhang avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.