Skip to content

Prevent catching intentional errors (IVS-371) #345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: development
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ def after_scenario(context, scenario):
execution_mode = context.config.userdata.get('execution_mode')
if execution_mode and execution_mode == 'ExecutionMode.TESTING':
if context.failed:
if context.step.error_message and not 'Behave errors' in context.step.error_message: #exclude behave output from exception logging
if context.step.error_message and not getattr(context, 'intentional_error_occured', False): #exclude behave output from exception logging
context.caught_exceptions.append(ExceptionSummary.from_context(context))
context.intentional_error_occured = False
context.scenario_outcome_state.append((len(context.gherkin_outcomes)-1, {'scenario': context.scenario.name, 'last_step': context.scenario.steps[-1]}))
elif execution_mode and execution_mode == 'ExecutionMode.PRODUCTION':
if context.failed:
Expand Down
1 change: 1 addition & 0 deletions features/steps/validation_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def generate_error_message(context, errors):
"""
Function to trigger the behave error mechanism by raising an exception so that errors are printed to the console.
"""
context.intentional_error_occured = True
assert not errors, "Errors occured:" + ''.join(f'\n - {error}' for error in errors)


Expand Down
6 changes: 3 additions & 3 deletions test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ def wrap_text(text, width):
print(tabulate.tabulate(table_data, headers=headers, tablefmt='fancy_grid'))

if base.startswith('fail'):
assert len(error_outcomes) > 0 or caught_exceptions
assert len(error_outcomes) > 0
elif base.startswith('pass'):
assert len(error_outcomes) == 0 and len(activating_outcomes) > 0
assert len(error_outcomes) == 0 and len(activating_outcomes) and not caught_exceptions
elif base.startswith('na'):
assert len(error_outcomes) == 0 and len(activating_outcomes) == 0
assert len(error_outcomes) == 0 and len(activating_outcomes) == 0 and not caught_exceptions

if error_outcomes:
tabulate_results = [
Expand Down
Loading