跳转到主要内容

用于发现/执行Ghost Inspector测试

项目描述

# pytest-ghostinspector

[![构建状态](https://travis-ci.org/harvard-dce/pytest-ghostinspector.svg?branch=master)

用于发现 & 执行 [Ghost Inspector](https://ghostinspector.com/) 测试。

## 特性

pytest-ghostinspector 是一个插件,它利用 pytest 框架和测试运行器通过 REST API 执行 Ghost Inspector 测试。您可以通过 Ghost Inspector UI 和/或测试记录器创建您的功能 Web 应用程序测试,然后使用 YAML 配置文件或命令行参数指定要执行的套件或单个测试。API 密钥和任何必要的测试变量也可以作为命令行参数或在 pytest.ini 文件中指定。

## 要求

  • 适用于 python 2.6 - 3.5

  • Ghost Inspector 账户 & api 密钥

## 安装

常规...

$ pip install pytest-ghostinspector

## 使用

此插件为 py.test 添加了几个命令行参数

ghostinspector:
  --gi_key=GI_KEY       Set the value for the Ghost Inspector API key
  --gi_start_url=GI_START_URL
                        Override the starting url value for the Ghost
                        Inspector tests
  --gi_suite=GI_SUITE   Id of a Ghost Inspector suite to execute
  --gi_test=GI_TEST     Id of a Ghost Inspector test to execute
  --gi_param=GI_PARAM   Querystring param (repeatable) to include in the API
                        execute request. Example: "--gi_param foo=bar"

### 通过命令行选项

安装后,通过 py.test 的命令行选项执行 Ghost Inspector 测试是最简单的方法

$ py.test --gi_key=hjkl1234 --gi_test=asdf0987

输出应类似于

============================== test session starts =============================
platform linux2 -- Python 2.7.10, pytest-2.8.3, py-1.4.30, pluggy-0.3.1
rootdir: /path/to/cwd, inifile:
plugins: ghostinspector-0.1.0
collected 1 items

. .

============================ 1 passed in 26.34 seconds =========================

### 通过 YAML 测试文件

如果您拥有足够多的测试或测试套件集合,您可以创建一个包含ids的YAML测试文件,插件将收集并执行它们。

# gi_test_my_tests.yml

suites:
  - id: abcd1234
  - id: fdsa9876

tests:
  - id: qwer4567

然后让py.test指向该YAML文件。

$ py.test gi_tests/gi_test_my_tests.yml

### pytest.ini

为了避免输入常用的选项,如–gi_key,请将它们包含在pytest.ini文件中的addopts中。

[pytest]
...
addopts =
    --gi_key=abcd1234
    --gi_param foo=bar

### 收集模式

0.4.0版本引入了–gi_collect_mode选项,用于控制插件如何处理测试收集。选项有:

  • “all” - 通过–gi-test/–gi-suite选项指定GI测试,同时启用标准文件系统测试发现。

  • “files” - 禁用通过–gi-test/–gi-suite进行的GI API收集。

  • “ids” - 禁用文件系统测试发现;仅收集通过–gi-test/–gi-suite标识的测试。

ids模式在您只想使用插件执行一组已知的测试和/或测试套件,并跳过通过搜索cwd可能找到的任何测试的情况下很有用。

默认情况下,如果没有显式传递模式,则包含–gi-test/–gi-suite将触发ids模式。

## 开发

欢迎贡献。可以使用tox运行测试。

## 许可证

在MIT许可证的条款下分发,pytest-ghostinspector是免费和开源软件。

## 版权

2015哈佛大学校长及院士

## 致谢

此插件是用[Cookiecutter](https://github.com/audreyr/cookiecutter)以及@hackebrot的[cCookiecutter-pytest-plugin](https://github.com/pytest-dev/cookiecutter-pytest-plugin)模板生成的。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

pytest-ghostinspector-0.4.0.tar.gz (15.8 kB 查看哈希)

上传时间

支持者