Skip to main content

a python base auto testing framework that programming oriented with Structured Language.

Project description

https://raw.githubusercontent.com/five3/pyops/master/images/testqa.png

☤ 说明

这是一款基于``pytest``封装,同时支持``关键字``和``BDD``,测试数据分离,面向编程,轻量级的,对上层自动化应用友好的基础测试框架。

其主要核心功能:

  • 支持关键字定义

  • 支持关键字组装

  • 测试数据透传

该框架的主要特点:

  • 基于``pytest``框架开发,支持原生插件

  • 同时具备``关键字``和``BDD``框架的特点

  • 无二次学习成本(Python|json)

  • 天然支持``测试数据分离``与传递

  • 对上层应用提供友好的封装接口

  • 支持脚本``Debug``调试

  • 代码量少(7个文件500行代码)

☤ 环境安装

pip install py-ops

或者使用下面命令安装最新版:

pip install git+https://github.com/five3/pyops.git

☤ 快速开始

使用该框架非常的方便,基本没有学习成本。安装完成之后,在任意目录执行如下命令创建一个测试项目:

pyops startproject test1

命令执行完成之后,会在当前目录创建一个[test1]目录,具体的目录结构如下:

|- test1
    |-- ah_ext
        |-- __init__.py
    |-- demo.json

接着在测试项目根目录(test1)执行如下命令运行测试:

pyops run

该命令默认会执行当前目录先全部的json用例文件,如果你希望只执行部分的json用例,则可以指定特定的文件名:

pyops run demo.jsom demo2.json

在执行完run命令后会在当前目录生成多个文件,具体的文件如下:

|- test1
    |-- ah_ext
        |-- __init__.py
    |-- demo.json
    |-- demo.py
    |-- pytest.ini
    |-- report.html
    |-- std.log

其中demo.py是由json文件生成的同名用例文件,这个是执行测试流程中的产物,也是执行测试的真正入口点。 report.html是测试报告,std.log则是测试的详细日志,pytest.ini自动生成的pytest配置文件。

如果你希望单独生成一个py用例文件,可以使用下面的命令:

pyops make demo.json

json文件中还可以对case配置disable字段,为true时则不会执行,不填时默认为false。 如果希望强制运行disable为true的用例,可以使用forcerun命令。

pyops forcerun

当然,你也可以通过原生的pytest命令来执行,前提是已经通过make、run命令生成了py文件。比如:

pytest demo.py::test_cls_name::test_case_name -s -v --force_run --pytest_report report.html

其中-s、-v是pytest原生的参数,–force_run是pyops插件参数,–pytest_report则是PyTestReport插件参数。

☤ 框架设计结构

https://raw.githubusercontent.com/five3/pyops/master/images/apic.png

☤ 自动生成用例说明

自动生成的demo.json测试用例内容如下:

{
    "name": "TestDemo",
    "desc": ".....background......",
    "tag": "smoking_test",
    "setup_class": [],
    "teardown_class": [],
    "setup": [],
    "teardown": [],
    "cases": {
        "test_add": {
            "desc": "",
            "tags": [],
            "data": {
                "x": 2,
                "y": 3,
                "expect": 5
            },
            "flow": ["调用add"],
            "check": ["检查add"]
        }
    }
}

自动生成的``ah_ext.__init__.py``文件内容如下:

import logging
from pyops.decorator import (make_check, make_flow, alias)

logger = logging.getLogger()

def add(x, y):
    print('add')
    return x + y

@alias('调用add')
@make_flow
def call_add(data):
    """
        data: 即json配置文件中的case节点下对应data字典对象
    """
    data['actual'] = add(data['x'], data['y'])

@alias('检查add')
@make_check
def check_add(data):
    """
        data: 即json配置文件中的case节点下对应data字典对象
    """
    return data['actual'] == data['expect']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-ops-0.1.4.tar.gz (10.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

py_ops-0.1.4-py3.7.egg (23.5 kB view details)

Uploaded Egg

py_ops-0.1.4-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file py-ops-0.1.4.tar.gz.

File metadata

  • Download URL: py-ops-0.1.4.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for py-ops-0.1.4.tar.gz
Algorithm Hash digest
SHA256 6c527db79cde68deec473078910e69ed08ad0a796b767bd259e490c7561f280b
MD5 8f16e9ac4e0d0c922d05904fc1eaff75
BLAKE2b-256 2e42b902577e562ea49f73770a3ba11ad9fd5aaae27f7fc885d23cc682e23755

See more details on using hashes here.

File details

Details for the file py_ops-0.1.4-py3.7.egg.

File metadata

  • Download URL: py_ops-0.1.4-py3.7.egg
  • Upload date:
  • Size: 23.5 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for py_ops-0.1.4-py3.7.egg
Algorithm Hash digest
SHA256 8338ddee3ff642ae4c8cc3627f87ed63b9d11813fcd890c4dd49dec038879a74
MD5 f3a89b03c19df717e51bf7e49c3a248e
BLAKE2b-256 5ffc6c4781f5138602680a50652673caf74d0e62b896748ea7add5f2f10a59b2

See more details on using hashes here.

File details

Details for the file py_ops-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: py_ops-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for py_ops-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4a7027531aea695d6904f3cccafaaf99c5a873f064fc26dc1d20b3727e9899a9
MD5 2058f6b999524643351602b7d3c8fab0
BLAKE2b-256 635792701cbf3f3edf8c535b1fabc510462f81784a56e17c56154ce9c730df1d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page