ReportPortal 在python下的应用介绍之—-python各框架整合

在上一篇文章之后,在安装之后,我们需要与我们现有的自动化测试对接。就Python而言,有几个框架可以直接使用。这是一个引言。

[En]

After the last article, after installation, we need to dock with our existing automated testing. As far as Python is concerned, there are several frameworks that can be used directly. Here’s an introduction.

首先,我们需要了解这是代理服务器模式,因此需要获取服务器上的身份验证信息。以这种方式接受:

[En]

First of all, we need to understand that this is agent server mode, so the authentication information on server needs to be obtained. To take in this way:

登录进系统后,输入对应的地址:http://xxx/ui/#user-profile,有对应的token信息:

ReportPortal 在python下的应用介绍之----python各框架整合

一、Nose

步骤:

[En]

Steps:

首先安装插件

[En]

Install the plug-in first

pip install nose-reportportal

让我们尝试以下简单的代码

[En]

Let’s try the following simple code

ReportPortal 在python下的应用介绍之----python各框架整合
# 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')

View Code

它怎麽工作?

[En]

How does it work?

有两种方法:

[En]

There are two ways:

1.文件形式

创建一个新文件rp.ini,如下所示:

[En]

Create a new file, rp.ini, as follows:

[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

但是,需要修改相应的信息。

[En]

However, the corresponding information needs to be modified.

运行:

[En]

Run:

nosetests xxx.py --with-reportportal --rp-config-file rp.ini

2.命令行形式

直接执行以下命令:

[En]

The following command directly:

nosetests xxx.py --with-reportportal --rp_uuid=xxxx rp_endpoint=http://xxx --rp_project=xxxx --rp_launch=xxx
--rp-config-file rp.ini

但在这一点上,您可能会遇到以下问题:

[En]

But at this point, you may encounter the following problem:

ReportPortal 在python下的应用介绍之----python各框架整合

我该怎么办?直接提出解决方案:

[En]

What should I do? Come up with the solution directly:

找到对应python的site-packages中的nose_reportportal文件夹,修改service.py文件

将行为116修改为如下所示:

[En]

Modify behavior 116 to look like this:

"parameters": None,

再运行一次,问题就可以解决了。

[En]

Run it again and the problem can be solved.

二、pytest

安装:

[En]

Installation:

pip install pytest-reportportal

添加配置文件config.cfg

[En]

Add profile 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'

需要修改相应的内容。

[En]

The corresponding content needs to be modified.

运行:

[En]

Run:

pytest xxxx.py --reportportal config.cfg

三、其它

剩下的就不详细介绍了,大同小异。

[En]

The rest will not be introduced in detail, it is more or less the same.

就像射频。

[En]

Like RF.

pip install robotframework-reportportal

Original: https://www.cnblogs.com/landhu/p/15963773.html
Author: Believer007
Title: ReportPortal 在python下的应用介绍之—-python各框架整合

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/6563/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

最近整理资源【免费获取】:   👉 程序员最新必读书单  | 👏 互联网各方向面试题下载 | ✌️计算机核心资源汇总