Skip to main content

pytest_th2_bdd

Project description

Th2 pytest bdd plugin

This is the plugin for pytest, which uses pytest-bdd plugin and th2 as backend.

Features

  • Typed tables in feature file;
  • Th2 client boilerplate isolation (auto th2 access factory creation, events hierarchy creation in background);
  • Test context.

Installation

  • From PyPI
    This package can be found on PyPI.

    pip install pytest-th2-bdd
    
  • From Source

    git clone https://github.com/th2-net/pytest-th2-bdd
    pip install pytest-th2-bdd/
    

Available fixtures

factory

This fixture yields th2 CommonFactory for which will be created from configuration located in configs/ directory.

ctx

This fixture is used for inter-steps communication. It has some important service items:

key purpose
__ROOT__ root events for each feature
__SCENARIO__ current scenario root event
__SCENARIO_START__ current scenario start datetime (in UTC)
__STEP__ current step event

Requirements

  • Prepared th2 test environment;
  • Configuration for th2 CommonFactory in configs/ directory;

How to use tables

Imagine, that you need to pass data as table in some step:

| field1 | field2 | ... | fieldN |
| 1      | 2      | ... | 3      |
...
| valN   | valK   | ... | valM   |
  1. You need to declare dataclass with header definition:
@dataclass
class SomeRow:
    field1: str
    field2: str
    ...
    fieldN: str
  1. Add field and converter at the desired step definition
@given(
    parsers.cfparse(
        "some step description {var1} ... \n{table}",
    ),
    converters={"table": Table(SomeRow)}, # converter setup
)
def some_step(var1, table: Table[SomeRow]): # Syntax hints via generics
    ...

How to start test process (with installed plugin)

pytest tests/

How to start test process (without installed plugin)

export PYTHONPATH=path/to/directory/with/this/repository:$PYTHONPATH
pytest -p th2_bdd.pytest tests/

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

pytest_th2_bdd-0.0.1.dev2320212357.tar.gz (6.7 kB view details)

Uploaded Source

File details

Details for the file pytest_th2_bdd-0.0.1.dev2320212357.tar.gz.

File metadata

File hashes

Hashes for pytest_th2_bdd-0.0.1.dev2320212357.tar.gz
Algorithm Hash digest
SHA256 2f9cd027b6604e741f3580b4a5a14460f909f959d603b26167973ef439a55026
MD5 8bfa89b3c396dd2382c23f223459648e
BLAKE2b-256 4ba6252d30cf59f9f39e289136baedb60fe3fbf3f89126d1ac22e942d8dd7248

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