Skip to content

Commit

Permalink
chg: doc: Add details on upgrading from 1.X.X to 2.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
dallinb committed Jul 21, 2022
1 parent 2c39cb8 commit ef17ac7
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ The file `tests/features/example.feature` could look something like:
Feature: Example of Testinfra BDD
Give an example of all the possible Given, When and Then steps.
The Given steps to skip the address and port tests when running under
GitHub actions are not part of the testinfra-bdd package itself, but are
required as GitHub/Azure does not allow Ping/ICMP traffic.
Scenario: Skip Tests if Host is Windoze
Given the host with URL "docker://sut" is ready within 10 seconds
# The system property can be one of:
Expand Down Expand Up @@ -112,7 +116,7 @@ Feature: Example of Testinfra BDD
When the pip package is testinfra-bdd
# Can check if the package is absent or present.
Then the pip package is present
And the pip package version is 0.3.0
And the pip package version is 1.0.6
# Check that installed packages have compatible dependencies.
And the pip check is OK
Expand Down Expand Up @@ -155,15 +159,21 @@ Feature: Example of Testinfra BDD
| udp://123 | listening |
| tcp://22 | not listening |
Scenario: Skip Tests Due to Environment Variable
Given the host with URL "docker://java11" is ready
When the environment variable PYTHONPATH is .:.. skip tests
Scenario: Check Network Address
Given the host with URL "docker://sut" is ready within 10 seconds
When the address is www.google.com
When the environment variable GITHUB_ACTIONS is true skip tests
And the address is www.google.com
Then the address is resolvable
And the address is reachable
Scenario: Check Network Address With Port
Given the host with URL "docker://sut" is ready within 10 seconds
When the address and port is www.google.com:443
When the environment variable GITHUB_ACTIONS is true skip tests
And the address and port is www.google.com:443
Then the address is resolvable
And the address is reachable
And the port is reachable
Expand All @@ -187,14 +197,15 @@ and `tests/step_defs/test_example.py` contains the following:

```python
"""Examples of step definitions for Testinfra BDD feature tests."""
import testinfra_bdd
from pytest_bdd import scenarios

scenarios('../features/example.feature')


# Ensure that the PyTest fixtures provided in testinfra-bdd are available to
# your test suite.
pytest_plugins = ['testinfra_bdd']
pytest_plugins = testinfra_bdd.PYTEST_MODULES
```

## "Given" Steps
Expand Down Expand Up @@ -280,3 +291,21 @@ Example:
Given the host with URL "docker://sut" is ready within 10 seconds
When the system property type is not Windoze skip tests
```

## Upgrading from 1.Y.Z to 2.0.0

We split the single package into multiple source files. This means a minor
but nonetheless breaking change in your step definitions (all feature files
can remain as they are). The change is how one sets `pytest_plugins`.

### Old Code

```python
pytest_plugins = ['testinfra_bdd']
```

### New Code

```python
pytest_plugins = testinfra_bdd.PYTEST_MODULES
```

0 comments on commit ef17ac7

Please sign in to comment.