{"id":18511963,"url":"https://github.com/airtestproject/pocounit","last_synced_at":"2025-08-02T21:36:20.095Z","repository":{"id":83501474,"uuid":"118999122","full_name":"AirtestProject/PocoUnit","owner":"AirtestProject","description":"Unittest framework for test automation","archived":false,"fork":false,"pushed_at":"2018-07-05T01:58:33.000Z","size":89,"stargazers_count":55,"open_issues_count":8,"forks_count":15,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-23T23:51:12.751Z","etag":null,"topics":["automation","game","unittest"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AirtestProject.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-26T03:11:24.000Z","updated_at":"2025-02-25T10:06:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"30f83d6d-1f6d-428e-9707-876491737099","html_url":"https://github.com/AirtestProject/PocoUnit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AirtestProject%2FPocoUnit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AirtestProject%2FPocoUnit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AirtestProject%2FPocoUnit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AirtestProject%2FPocoUnit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AirtestProject","download_url":"https://codeload.github.com/AirtestProject/PocoUnit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987056,"owners_count":21028891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","game","unittest"],"created_at":"2024-11-06T15:31:00.283Z","updated_at":"2025-04-09T05:33:00.210Z","avatar_url":"https://github.com/AirtestProject.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n.. raw:: html\n    \n    \u003cdiv\u003e\n        \u003cimg src='doc/img/logo-simple-pocounit.png' width='150px' height='150px' alt='pocounit' /\u003e\n    \u003c/div\u003e\n\nPocoUnit (unittest framework for poco)\n======================================\n\n如需构建自动化工程项目，请直接使用 `my-testflow`_\n\n可配合airtest和poco使用的单元测试框架。规范了脚本编写的格式，提供流式日志（stream log）记录服务，然后可以使用 `PocoResultPlayer`_ 将运行的内容回放。\n\nInstallation\n------------\n\n.. code-block:: bash\n    \n    pip install pocounit\n\n\n用法\n----\n\n首先需要继承基类PocoTestCase实现项目组自己的MyBaseTestCase，在MyBaseTestCase预处理中将需要用到的对象准备好（包括实例化hunter和poco和动作捕捉），以后在其余用例中继承MyBaseTestCase即可。\n\n基本用法可参考一下代码模板。\n\n.. code-block:: python\n\n    # coding=utf-8\n\n    from pocounit.case import PocoTestCase\n    from pocounit.addons.poco.action_tracking import ActionTracker\n\n    from poco.drivers.unity3d import UnityPoco\n\n\n    class MyBaseTestCase(PocoTestCase):\n        @classmethod\n        def setUpClass(cls):\n            super(MyBaseTestCase, cls).setUpClass()\n            cls.poco = UnityPoco()\n\n            # 启用动作捕捉(action tracker)\n            action_tracker = ActionTracker(cls.poco)\n            cls.register_addon(action_tracker)\n\n\n然后可以开始编写自己的testcase\n\n.. code-block:: python\n\n    # coding=utf8\n\n    from ... import MyBaseTestCase\n\n\n    # 一个文件里建议就只有一个TestCase\n    # 一个Case做的事情尽量简单，不要把一大串操作都放到一起\n    class MyTestCase(MyBaseTestCase):     \n        def setUp(self):\n            # 可以调用一些前置条件指令和预处理指令\n            pass\n\n        # 函数名就是这个，用其他名字无效\n        def runTest(self):\n            # 普通语句跟原来一样\n            self.poco(text='角色').click()\n            \n            # 断言语句跟python unittest写法一模一样\n            self.assertTrue(self.poco(text='最大生命').wait(3).exists(), \"看到了最大生命\")\n\n            self.poco('btn_close').click()\n            self.poco('movetouch_panel').offspring('point_img').swipe('up')\n\n        def tearDown(self):\n            # 如果没有清场操作，这个函数就不用写出来\n            pass\n\n        # 不要写以test开头的函数，除非你知道会发生什么\n        # def test_xxx():\n        #     pass\n\n\n    if __name__ in '__main__':\n        import pocounit\n        pocounit.main() \n\n\n.. _my-testflow: https://github.com/AirtestProject/my-testflow\n.. _PocoResultPlayer: http://poco.readthedocs.io/en/latest/source/doc/about-test-result-player.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairtestproject%2Fpocounit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fairtestproject%2Fpocounit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairtestproject%2Fpocounit/lists"}