pytest结果数据库和html报告器

pytest-ochrus的Python项目详细描述


ochrus项目是一个完整的解决方案,可以轻松地开发功能(黑/灰盒)自动化测试。

ochrus项目包含以下组件:

  1. ochrus:支持功能自动化测试的类和模块
  2. ochrus srv:详细结果数据库服务器。
  3. pytest ochrus:pytest插件,请参阅下面的注释…

NOTE: Ochrus Project choose Pytest (https://www.pytest.org) open source project as its testing framework.

Pytest is an easy to use and powerful testing framework that support the most common Python unit framework such and “unittest” and “Nose”.

ochrus库:

提供类和模块以支持功能自动化测试 应该与pytest框架一起使用。 文档应该很快就可以在wiki上找到,以后可以在:http://www.ochrus.com

To install:

$ pip install ochrus

pytest ochrus:

pytest插件,需要与pytest一起安装 它用于通过rest协议将测试结果发送到“ochrus srv”(见下文) (代码:https://github.com/ochrus/pytest-ochrus

To install:

$ pip install pytest
$ pip install pytest-ochrus

ochrus服务器:

ochrus服务器是一个完整的无堆栈应用程序,它包括一个保存测试结果的数据库和一个显示结果的html接口。 用户可以看到彩色的在线结果,结果历史和比较。 服务器支持restful api,目前只有pytest ochrus可以与之通信,但实际上它可以为任何用任何语言编写的xunit框架提供服务。

To install:

The server is available as Docker image and can be run directly from docker hub as followed:

$ docker run -d -p 80:8000 -v db:/ochrus/db --name ochrus_srv ochrus/ochrus_srv:demo

要求

  • python 2.7版
  • pytest
  • Docker(仅在主机服务器上)

安装

客户端:

$ pip install pytest
$ pip install pytest_ochrus
$ pip install ochrus

服务器:

按照https://docs.docker.com/engine/installation/中的说明在主机服务器上安装Docker。

例如:对于centos:

$ yum install -y yum-utils device-mapper-persistent-data lvm2
$ yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
$ yum install docker-ce
$ systemctl start docker      #run the service
$ systemctl enable docker     #make it start on boot

要安装“ochrus_srv”,请运行以下命令:

$ docker run -d -p 80:8000 -v db:/ochrus/db --name ochrus_srv ochrus/ochrus_srv:demo

The above Docker command will do the following:

  1. Download the ‘ochrus_srv:demo’ image from the Docker public Hub.
  2. Run it at the background and give it the name ‘ochrus_srv’.
  3. Expose its 8000 port to port 80 on the running host.
  4. Create a persistent data-base at default Docker volume location at: ‘/var/lib/docker/volumes/db/’

注释

  1. 上面的docker命令应该只运行一次,运行之后:
docker stop ochrus_srv   to stop the server
docker start ochrus_srv  to run the server
  1. 确保主机服务器上的端口80空闲。

执行:

在客户端

Define the ochrus-srv IP address: The ‘ochrus’ name must be define at the ‘/etc/hosts’ file. e.g.: 192.168.1.1 ochrus

Replace 192.168.1.1 with your Docker host machine IP address

  1. 运行测试:只需按照pytest执行指令运行pytest。
  2. 您可以为正在运行的会话命名,如下所示:
$ pytest --session_name="mySessionName"

The name will be displayed at the HTML report at the ochres server

NOTE: You can give any name that will describe the running session

Recommended: *product_name-version_number.build_number*

使用EclipseIDE

注意:以下说明适用于:eclipse oxygen.1a release(4.7.1a)

  1. 安装EclipseIDE

  2. 运行eclipse并安装“*pydev*”插件。

    转到:*help eclipse markeplace…*,在搜索框中编写“*pydev*”,然后单击“go”按钮。

    等到找到pydev插件,然后单击“install”按钮

  3. 创建一个新的pydev项目(*file new other…*pydev pydev项目)

  4. 转到:*windows preferences pydev pyunit test runner*;选择:py.test runner,单击“应用”

  5. 创建一个pytest脚本,右键单击并选择run as python unit test运行它

  6. 要在一个特殊目录中运行所有测试,只需右键单击该目录并选择run as python unit test

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
选项卡内的java 安卓工具栏   java接口VS API VS公共类   无法解析java。lang.ClassNotFoundException:在安卓 studio中找不到类“com.example.安卓.camera2basic.AutoFitTextureView”?   java等待线程正常完成   java在JTable中的prepareRenderer方法中编辑单元格数据是否可行?   java SessionNotCreatedException selenium webdriver   java Android Studio Gradle CreateProcess错误=2   java找不到适用于异常(int)的构造函数   javascript如何在不使用正则表达式的情况下检查输入是否为表情符号?   从JAVA运行ant时,JAVA_HOME变量不正确   long的java min值引发异常   java如何在这段代码中实现侦听器?   带有透明文本的java Android按钮   图像Java扫描仪问题(JFrame)   java模拟输入蒸汽似乎在Junit测试的第一次输入中就被吃掉了   压缩Java Deflater,现在和将来的结果相同(确定性)   java JTable getModel()。setValueAt从数组中删除第一个元素   java我有不同于编译器和计算器的价值   使用C#客户端调用基本身份验证java webservice   java相同类型的多个@Embedded字段在持久化后始终为空