Skip to content

Commit

Permalink
Prevent catching intentional errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghesselink committed Jan 29, 2025
1 parent d4e3d34 commit a742ddb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
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

0 comments on commit a742ddb

Please sign in to comment.