ochrus功能测试自动化基础设施
ochrus的Python项目详细描述
ochrus项目是一个完整的解决方案,可以轻松地开发功能(黑/灰盒)自动化测试。
ochrus项目包含以下组件:
- ochrus:支持功能自动化测试的类和模块
- ochrus srv:详细结果数据库服务器。
- 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:
- Download the ‘ochrus_srv:demo’ image from the Docker public Hub.
- Run it at the background and give it the name ‘ochrus_srv’.
- Expose its 8000 port to port 80 on the running host.
- Create a persistent data-base at default Docker volume location at: ‘/var/lib/docker/volumes/db/’
注释:
- 上面的docker命令应该只运行一次,运行之后:
docker stop ochrus_srv to stop the server docker start ochrus_srv to run the server
- 确保主机服务器上的端口80空闲。
执行:
在客户端:
- 运行测试:只需按照pytest执行指令运行pytest。
- 您可以为正在运行的会话命名,如下所示:
$ 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)
安装EclipseIDE
运行eclipse并安装“*pydev*”插件。
转到:*help eclipse markeplace…*,在搜索框中编写“*pydev*”,然后单击“go”按钮。
等到找到pydev插件,然后单击“install”按钮
创建一个新的pydev项目(*file new other…*pydev pydev项目)
转到:*windows preferences pydev pyunit test runner*;选择:py.test runner,单击“应用”
创建一个pytest脚本,右键单击并选择run as python unit test运行它
要在一个特殊目录中运行所有测试,只需右键单击该目录并选择run as python unit test
安装EclipseIDE
运行eclipse并安装“*pydev*”插件。
转到:*help eclipse markeplace…*,在搜索框中编写“*pydev*”,然后单击“go”按钮。
等到找到pydev插件,然后单击“install”按钮
创建一个新的pydev项目(*file new other…*pydev pydev项目)
转到:*windows preferences pydev pyunit test runner*;选择:py.test runner,单击“应用”
创建一个pytest脚本,右键单击并选择run as python unit test运行它
要在一个特殊目录中运行所有测试,只需右键单击该目录并选择run as python unit test