接上一篇,装完之后,需要对接我们现有的自动化测试。就Python而言,有几种框架可以直接使用,这里介绍一下
首先,我们需要了解这是agent server模式,所以server上认证信息需要拿到。按这种方法拿:
登录进系统后,输入对应的地址:http://xxx/ui/#user-profile,有对应的token信息:
一、Nose
步骤:
先安装插件
pip install nose-reportportal
我们拿下面这段简单代码来尝试
# coding = utf-8 # author:huzq import logging log = logging.getLogger(__name__) class Testclass: def __init__(self): pass def setup(self): print('start') def teardown(self): print('stop') def testfunc1(self): """dafdfdfd""" log.info("bbbbd") print('this is case1') def testfunc2(self): log.info("bbbbd") print('this is case2') def testfunc3(self): log.info("bbbbd") print('this is case3')
怎么运行呢?
两种方法:
1.文件形式
新建文件rp.ini,如下内容:
[base] rp_uuid = fb586627-32be-47dd-93c1-678873458a5f rp_endpoint = http://192.168.1.10:8080 rp_project = user_personal rp_launch = AnyLaunchName rp_launch_tags = Nose rp_launch_description = Smoke test
不过对应的信息需要修改
运行:
nosetests xxx.py --with-reportportal --rp-config-file rp.ini
2.命令行形式
直接下面的命令:
nosetests xxx.py --with-reportportal --rp_uuid=xxxx rp_endpoint=http://xxx --rp_project=xxxx --rp_launch=xxx
--rp-config-file rp.ini
但这个时候,你可能会遇到下面这个问题:
怎么办呢?直接给出解决方案吧:
找到对应python的site-packages中的nose_reportportal文件夹,修改service.py文件
修改第116行为下面这个样子:
"parameters": None,
再次运行,问题可以解决。
二、pytest
安装:
pip install pytest-reportportal
添加配置 文件config.cfg
[tool:pytest] rp_uuid = 55466cae-8588-452c-9400-9ce4c5960e98 rp_endpoint = https://xxxx rp_project = user rp_launch = default_TEST_EXAMPLE rp_launch_attributes = 'PyTest' 'Smoke' rp_launch_description = 'Smoke test' rp_ignore_errors = True rp_ignore_attributes = 'xfail' 'usefixture'
对应的内容要修改
运行:
pytest xxxx.py --reportportal config.cfg
三、其它
其它的就不详细介绍,大同小异
比如RF
pip install robotframework-reportportal