Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,14 @@
"version": "0.2.0",
"configurations": [
{
"name": "Python: Behave",
"name": "Python: Pytest-bdd",
"type": "python",
"cwd": "${workspaceRoot}",
"request": "launch",
"module": "behave",
"module": "pytest",
"args": [
"-s",
"-k",
"-D",
"Driver_type=",
"-D",
"TestExecution_language=es",
"-D",
"Server_enabled=false",
"-D",
"TestExecution_environment=qa",
"features/component/feature1/example.feature"
"-m",
"1"
],
"justMyCode": false
}
Expand Down
21 changes: 11 additions & 10 deletions common/steps/my_steps.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""
Copyright (c) Telefónica Digital. CDCO QA Team <qacdco@telefonica.com>
"""
from pytest_bdd import given, when, then, step, parsers

from toolium_telefonica.behave.decorators import step
from toolium_telefonica.behave.steps.tools.storage import add_value_to_storage_with_key

@given(parsers.parse('the value "{expected_result:d}" is stored'), target_fixture="expected_result")
def set_expected_result(expected_result):
return expected_result

@step('I add "{value1}" to "{value2}" and store the result as "{name}"')
def add_values_and_store_result(context, value1, value2, name):
result = value1 + value2
context.logger.info(f'Result generated: {result}')
add_value_to_storage_with_key(context, result, name)
@when(parsers.parse('I add "{sum1:d}" to "{sum2:d}" and store the result'), target_fixture="real_result")
def set_real_result(sum1, sum2):
return sum1 + sum2

@then('the two values stored are equal')
def compare_results(expected_result, real_result):
assert expected_result == real_result
File renamed without changes.
7 changes: 7 additions & 0 deletions common/tests/test_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from pytest_bdd import scenarios
from common.steps import *


# Escenarios
scenarios('component/feature1')
scenarios('component/feature2')
5 changes: 0 additions & 5 deletions features/component/feature1/environment.py

This file was deleted.

6 changes: 3 additions & 3 deletions features/component/feature1/example.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Feature: Example

@1
Scenario Outline: Example 1
Given the value "5" is stored in the context storage with key "expected_result"
When I add "<value1>" to "<value2>" and store the result as "result"
Then the values stored in the context storage with keys "expected_result" and "result" are equal
Given the value "5" is stored
When I add "<value1>" to "<value2>" and store the result
Then the two values stored are equal

Examples:
| value1 | value2 |
Expand Down
Empty file.
5 changes: 0 additions & 5 deletions features/component/feature1/steps/steps.py

This file was deleted.

Empty file.
5 changes: 0 additions & 5 deletions features/component/feature2/environment.py

This file was deleted.

6 changes: 3 additions & 3 deletions features/component/feature2/example.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Feature: Example

@1
Scenario Outline: Example 1
Given the value "5" is stored in the context storage with key "expected_result"
When I add "<value1>" to "<value2>" and store the result as "result"
Then the values stored in the context storage with keys "expected_result" and "result" are equal
Given the value "5" is stored
When I add "<value1>" to "<value2>" and store the result
Then the two values stored are equal

Examples:
| value1 | value2 |
Expand Down
Empty file.
5 changes: 0 additions & 5 deletions features/component/feature2/steps/steps.py

This file was deleted.

5 changes: 5 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[pytest]
testpaths = common/tests
bdd_features_base_dir = features
markers:
1: run tests labeled as @1
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
toolium-telefonica==5.2.0
pytest-bdd==6.1.1