diff --git a/README.md b/README.md index 18150639..d54c620e 100644 --- a/README.md +++ b/README.md @@ -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/)** diff --git a/examples/behave/README.md b/examples/behave/README.md new file mode 100644 index 00000000..9bceecad --- /dev/null +++ b/examples/behave/README.md @@ -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). diff --git a/examples/behave/qase.config.json b/examples/behave/qase.config.json new file mode 100644 index 00000000..c263159a --- /dev/null +++ b/examples/behave/qase.config.json @@ -0,0 +1,30 @@ +{ + "mode": "testops", + "fallback": "off", + "debug": true, + "report": { + "driver": "local", + "connection": { + "local": { + "path": "./build/qase-report", + "format": "json" + } + } + }, + "testops": { + "api": { + "token": "", + "host": "qase.io" + }, + "run": { + "title": "Behave run", + "description": "Behave examples", + "complete": true + }, + "defect": false, + "project": "", + "batch": { + "size": 200 + } + } +} diff --git a/examples/behave/requirements.txt b/examples/behave/requirements.txt new file mode 100644 index 00000000..10df73c4 --- /dev/null +++ b/examples/behave/requirements.txt @@ -0,0 +1,2 @@ +behave>=1.2.6 +qase-behave>=1.0.0 diff --git a/examples/behave/tests/features/parametrized.feature b/examples/behave/tests/features/parametrized.feature new file mode 100644 index 00000000..d28ccf7e --- /dev/null +++ b/examples/behave/tests/features/parametrized.feature @@ -0,0 +1,24 @@ +Feature: Parametrized Tests + + Scenario Outline: Test with parameters success + Given I have a test with parameters "" and "" + 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 "" and "" + When I run it + Then it should fail + + Examples: + | param1 | param2 | + | 1 | 2 | + | 3 | 4 | + | 5 | 6 | diff --git a/examples/behave/tests/features/simple.feature b/examples/behave/tests/features/simple.feature new file mode 100644 index 00000000..237da32a --- /dev/null +++ b/examples/behave/tests/features/simple.feature @@ -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 diff --git a/examples/behave/tests/features/steps/steps.py b/examples/behave/tests/features/steps/steps.py new file mode 100644 index 00000000..adccd885 --- /dev/null +++ b/examples/behave/tests/features/steps/steps.py @@ -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 diff --git a/examples/behave/tests/features/suites.feature b/examples/behave/tests/features/suites.feature new file mode 100644 index 00000000..963f7fb0 --- /dev/null +++ b/examples/behave/tests/features/suites.feature @@ -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