Skip to content

Commit

Permalink
feat: add Behave example project
Browse files Browse the repository at this point in the history
  • Loading branch information
gibiw committed Nov 28, 2024
1 parent 0373a89 commit 1bd37c2
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Monorepo containing [Qase TestOps](https://qase.io) integration tools for Python
- **[qase-robotframework](/qase-robotframework)**
Reporter for Robot Framework, enabling seamless integration with Qase TestOps.

- **[qase-behave](/qase-behave)**
Reporter for Behave, enabling seamless integration with Qase TestOps.

### Libraries

- **[qase-python-commons](/qase-python-commons/)**
Expand Down
44 changes: 44 additions & 0 deletions examples/behave/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
### Behave Example

This is a sample project demonstrating how to write and execute tests using the Behave framework with integration to
Qase Test Management.

---

## Prerequisites

Ensure that the following tools are installed on your machine:

1. [Python](https://www.python.org/) (version 3.7 or higher is recommended)
2. [pip](https://pip.pypa.io/en/stable/)

---

## Setup Instructions

1. Clone this repository by running the following commands:
```bash
git clone https://github.com/qase-tms/qase-python.git
cd qase-python/examples/behave
```

2. Install the project dependencies:
```bash
pip install -r requirements.txt
```

3. Create a `qase.config.json` file in the root of the project. Follow the instructions on
[how to configure the file](https://github.com/qase-tms/qase-python/tree/main/qase-behave/docs/configuration).

4. To run tests and upload the results to Qase Test Management, use the following command:
```bash
behave --format=qase.behave.formatter:QaseFormatter
```
This will execute the tests and display the results in the terminal.

---

## Additional Resources

For more details on how to use this integration with Qase Test Management, visit
the [Qase Behave documentation](https://github.com/qase-tms/qase-python/tree/main/qase-behave).
30 changes: 30 additions & 0 deletions examples/behave/qase.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"mode": "testops",
"fallback": "off",
"debug": true,
"report": {
"driver": "local",
"connection": {
"local": {
"path": "./build/qase-report",
"format": "json"
}
}
},
"testops": {
"api": {
"token": "<token>",
"host": "qase.io"
},
"run": {
"title": "Behave run",
"description": "Behave examples",
"complete": true
},
"defect": false,
"project": "<project_code>",
"batch": {
"size": 200
}
}
}
2 changes: 2 additions & 0 deletions examples/behave/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
behave>=1.2.6
qase-behave>=1.0.0
24 changes: 24 additions & 0 deletions examples/behave/tests/features/parametrized.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Feature: Parametrized Tests

Scenario Outline: Test with parameters success
Given I have a test with parameters "<param1>" and "<param2>"
When I run it
Then it should pass

Examples:
| param1 | param2 |
| 1 | 2 |
| 3 | 4 |
| 5 | 6 |


Scenario Outline: Test with parameters failed
Given I have a test with parameters "<param1>" and "<param2>"
When I run it
Then it should fail

Examples:
| param1 | param2 |
| 1 | 2 |
| 3 | 4 |
| 5 | 6 |
35 changes: 35 additions & 0 deletions examples/behave/tests/features/simple.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Feature: Simple tests

Scenario: Test without annotations success
Given I have a simple test
When I run it
Then it should pass

Scenario: Test without annotations failed
Given I have a simple test
When I run it
Then it should fail

@qase.id:1
Scenario: Test with QaseID success
Given I have a simple test
When I run it
Then it should pass

@qase.id:2
Scenario: Test with QaseID failed
Given I have a simple test
When I run it
Then it should fail

@qase.fields:{"description":"It_is_simple_test"}
Scenario: Test with Fields success
Given I have a simple test
When I run it
Then it should pass

@qase.fields:{"description":"It_is_simple_test"}
Scenario: Test with Fields failed
Given I have a simple test
When I run it
Then it should fail
23 changes: 23 additions & 0 deletions examples/behave/tests/features/steps/steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from behave import *

@given('I have a simple test')
def step_impl(context):
pass

@given('I have a test with parameters "{param1}" and "{param2}"')
def step_given_test_with_parameters(context, param1, param2):
pass

@when('I run it')
def step_impl(context):
pass


@then('it should pass')
def step_impl(context):
pass


@then('it should fail')
def step_impl(context):
assert False
25 changes: 25 additions & 0 deletions examples/behave/tests/features/suites.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Feature: Simple1 tests

@qase.suite:MySuite
Scenario: Test with single suite success
Given I have a simple test
When I run it
Then it should pass

@qase.suite:MySuite
Scenario: Test with single suite failed
Given I have a simple test
When I run it
Then it should fail

@qase.suite:MySuite||SubSuite
Scenario: Test with multiple suite success
Given I have a simple test
When I run it
Then it should pass

@qase.suite:MySuite||SubSuite
Scenario: Test with multiple suite failed
Given I have a simple test
When I run it
Then it should fail

0 comments on commit 1bd37c2

Please sign in to comment.