如需构建自动化工程项目,请直接使用 my-testflow
可配合airtest和poco使用的单元测试框架。规范了脚本编写的格式,提供流式日志(stream log)记录服务,然后可以使用 PocoResultPlayer 将运行的内容回放。
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
Forkers
kaluluosi zhangfeilynu lijinhua163 lzhang1 windofthesky 47045039 guo2009042078 a287157966 zhangyuefei myhololens lvshuiyiqing caohe2018 minhnt33 kevinwilson121 tester-xmpocounit's Issues
请问下PocoUnit怎么生成html报告?
pycharm/_jb_unittest_runner 模式不支持
Launching unittests with arguments python -m unittest Q6TestCase.Q6TestCase in G:\AutoTest\Q6-Airtest\my-testflow\Q6\lib\Q6TestCase
Traceback (most recent call last):
File "D:\PyCharm Community Edition 2017.3.5\helpers\pydev\pydevd.py", line 1668, in <module>
main()
File "D:\PyCharm Community Edition 2017.3.5\helpers\pydev\pydevd.py", line 1662, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "D:\PyCharm Community Edition 2017.3.5\helpers\pydev\pydevd.py", line 1072, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "D:\PyCharm Community Edition 2017.3.5\helpers\pycharm\_jb_unittest_runner.py", line 35, in <module>
main(argv=args, module=None, testRunner=unittestpy.TeamcityTestRunner, buffer=not JB_DISABLE_BUFFERING)
File "D:\Python27\Lib\unittest\main.py", line 94, in __init__
self.parseArgs(argv)
File "D:\Python27\Lib\unittest\main.py", line 149, in parseArgs
self.createTests()
File "D:\Python27\Lib\unittest\main.py", line 158, in createTests
self.module)
File "D:\Python27\Lib\unittest\loader.py", line 130, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "D:\Python27\Lib\unittest\loader.py", line 105, in loadTestsFromName
return self.loadTestsFromTestCase(obj)
File "D:\Python27\Lib\unittest\loader.py", line 56, in loadTestsFromTestCase
loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames))
TypeError: __init__() takes exactly 1 argument (2 given)
照着代码复制了一遍,也按照了pocounit库,但是debug的时候出现了这个报错,请问下这个是啥问题?
from pocounit.case import PocoTestCase
from pocounit.addons.poco.action_tracking import ActionTracker
from poco.drivers.unity3d import UnityPoco
class GxxTestCase(PocoTestCase):
@classmethod
def setUpClass(cls):
super(GxxTestCase, cls).setUpClass()
cls.poco = UnityPoco(('<ip>', 5001))
# 启用动作捕捉(action tracker)
action_tracker = ActionTracker(cls.poco)
cls.register_addon(action_tracker)
poco的帮助文档没了
在iOS设备上跑pocoUnit时不能生成录屏MP4文件
我在使用GitHub上的my-testflow项目时,是可以生成一个录屏的mp4文件的,使用PocoResultPlayer 可以将运行的内容回放。但是我自己写了一个ios端的demo,运行是正常的但是没有生成mp4录屏文件,使用pocoresultplayer回放时,有点击操作,但是屏幕是黑的
脚本远程调用
请问下airetest可不可以远程调用,比如我把脚本放在服务端,本机通过调用服务端的脚本来测试?adb能否连接到手机?
SetUpClass() is not listening while running test suite.
Hi, I have done the setup for multiple test cases to run using pocotestsuite module but whenever executing runner file, only listening to the setUp() function, not listening the setUpClass(). Can you provide clear details on how to execute the multiple test cases simultaneously.
在ios上跑pocounit报这个warning,Fail to stop result emitter: "SiteSnapshot"
在ios上跑pocounit报下列warning,有什么办法屏蔽掉吗?
./usr/local/lib/python3.7/site-packages/pocounit/case.py:211: UserWarning: Fail to stop result emitter: "SiteSnapshot". You can report this error to the developers or just ignore it. Error message:
Labconfig.getIsLogJavis():False
"Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/pocounit/case.py", line 207, in run
emitter.stop()
File "/usr/local/lib/python3.7/site-packages/pocounit/result/site_snapshot.py", line 32, in stop
self.snapshot('caseEnd')
File "/usr/local/lib/python3.7/site-packages/pocounit/result/site_snapshot.py", line 38, in snapshot
self.snapshot_screen(site_id)
File "/usr/local/lib/python3.7/site-packages/pocounit/result/site_snapshot.py", line 60, in snapshot_screen
b64img, fmt = self.poco.snapshot()
File "/usr/local/lib/python3.7/site-packages/poco/pocofw.py", line 433, in snapshot
return self.agent.screen.getScreen(width)
File "/usr/local/lib/python3.7/site-packages/poco/utils/airtest/screen.py", line 21, in getScreen
return base64.b64encode(open(savepath, 'rb').read()), 'png'
TypeError: expected str, bytes or os.PathLike object, not NoneType
"
.format(emitter.class.name, traceback.format_exc()))
怎样测试完成才能不要生成图片?
如何使用unittest的discover()方法批量加载TestCase
suite = unittest.defaultTestLoader.discover('.', 'test*.py')
是否支持类似unittest的discover()方法批量加载TestCase,应该如何使用?
试了下,直接用unittest.makeSuite,unittest.findTestCases,unittest.defaultTestLoader.loadTestsFromModule,unittest.defaultTestLoader.discover这些都会报错__init__() takes 1 positional argument but 2 were given,是因为pocounit里case类的初始化和unittest里case类的初始化不一样?
Pocounit-results可以自定义文件名和时间吗
Pocounit-results生成的结果会把上一次的覆盖掉,想通过设备和时间来区分
怎么批量执行用例
怎么批量执行用例,聚合报告,有建议吗
请问下这个文件还会完善吗PocoUnit/pocounit/addons/airtest/action_tracking.py
Poco Test Result Player有问题
pocounit怎么设置多机同时运行
我用pocounit框架写了能运行的脚本,但接两台android设备,只能第一台连接上的能跑,后面连的都不会执行,也没报错
How to generate HTML report for pocounit testcases ?
How to generate HTML report for pocounit testcases like htmltestrunner generates for python unittest library ?
Problem with yosemite recording (Error: Unknown option: -g)
Current Behavior
My PocoTestResultPlayer is not showing any video.
Investigating further, i've tried to run the adb commands by-hand on my terminal (MacOs).
When the yosemite.apk install command is run, I get an Error: Unknown option: -g
If I remove the -g option from the command, yosemite is installed succesfully, but then it won't have granted permissions.
I've tried installing yosemite manually and giving permissions by manually starting a record from the app. Then, if I run my tests again, it works correctly, but it records a vertical video with my horizontal app on the middle, and big black margins on top and bottom
Expected Behavior
yosemite.apk should install with no errors and be able to record a video
Context (Environment)
Test running from MacOs
Samsung Galaxy S4 (Android 5.0.1)
Unity videogame with agent running succesfully
Running test with PyCharm with a normal run (not unit test). My test runs okay, only screen recording is failing.
My requirements.txt:
pocounit==1.0.40
airtest==1.1.3
pocoui==1.0.79
ADB version is:
Android Debug Bridge version 1.0.40
Version 4986621
Installed as /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/airtest/core/android/static/adb/mac/adb
Command executed by the test:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/airtest/core/android/static/adb/mac/adb -s c818cb7a install -t -g -r /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/airtest/core/android/static/apks/Yosemite.apk
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.