Skip to content

Commit

Permalink
test(chore): Add Automatic Screenshots on Test Failures and Errors
Browse files Browse the repository at this point in the history
Set `logScreenshotOnFail` property.

Forced a failure in login scenario.

Closes #8330
  • Loading branch information
noeliaSD committed Nov 22, 2022
1 parent 7de8961 commit 8e312bd
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion test/ui-test/testSuites/global_shared/scripts/bdd_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@OnScenarioStart
def hook(context):
context_init(context)
context_init(context, testSettings)

@OnScenarioEnd
def hook(context):
Expand Down
5 changes: 4 additions & 1 deletion test/ui-test/testSuites/global_shared/steps/startupSteps.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
_search_images = "search_images"
_scenario_name = "scenario_name"

def context_init(context):
def context_init(context, testSettings, screenshot_on_fail = True):
# With this property it is enabled that every test failure will cause Squish to take a screenshot of the desktop when the failure occurred
testSettings.logScreenshotOnFail = screenshot_on_fail

filesMngr.erase_directory(_status_qt_path)
context.userData = {}
context.userData[_aut_name] = _status_desktop_app_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@OnFeatureStart
def hook(context):
init_steps.context_init(context)
init_steps.context_init(context, testSettings)
init_steps.signs_up_process_steps(context, _user, _password)

@OnFeatureEnd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../testSuites/global_shared/"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../src/"))

from steps.startupSteps import *
import steps.startupSteps as init_steps

# Global properties for the specific feature
_user = "tester123"
_password = "TesTEr16843/!@00"

@OnFeatureStart
def hook(context):
context_init(context)
signs_up_process_steps(context, _user, _password)
init_steps.context_init(context, testSettings)
init_steps.signs_up_process_steps(context, _user, _password)

@OnFeatureEnd
def hook(context):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

@OnFeatureStart
def hook(context):
init_steps.context_init(context)
init_steps.context_init(context, testSettings)
init_steps.signs_up_process_steps(context, _user, _password)
init_steps.the_user_joins_chat_room(_chat_room1)
init_steps.the_user_joins_chat_room(_chat_room2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../testSuites/global_shared/"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../src/"))

import steps.startupSteps as init_steps

# Global properties for the specific feature
_user = "tester123"
_password = "TesTEr16843/!@00"
_chat_room = "test"

@OnFeatureStart
def hook(context):
context_init(context)
signs_up_process_steps(context, _user, _password)
the_user_joins_chat_room(_chat_room)
init_steps.context_init(context, testSettings)
init_steps.signs_up_process_steps(context, _user, _password)
init_steps.the_user_joins_chat_room(_chat_room)

@OnFeatureEnd
def hook(context):
Expand All @@ -22,7 +24,7 @@ def hook(context):

@OnScenarioStart
def hook(context):
the_user_opens_the_chat_section()
init_steps.the_user_opens_the_chat_section()

@OnStepEnd
def hook(context):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@OnFeatureStart
def hook(context):
init_steps,context_init(context)
init_steps.context_init(context, testSettings)
init_steps.login_process_steps(context, _user, _password, _data_folder_path)

@OnFeatureEnd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@OnFeatureStart
def hook(context):
init_steps.context_init(context)
init_steps.context_init(context, testSettings)
init_steps.a_first_time_user_lands_on_and_generates_new_key(context)
init_steps.the_user_inputs_username(_user)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@OnFeatureStart
def hook(context):
init_steps.context_init(context)
init_steps.context_init(context, testSettings)
init_steps.a_first_time_user_lands_on_and_generates_new_key(context)

@OnFeatureEnd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Feature: Status Desktop login
And the user signs up with username "<username>" and password "<password>"
And the user lands on the signed in app
When the user restarts the app
And the user "<username>" logs in with password "<password>"
And the user "<username>" logs in with password "TesTEr16843/!@11"
Then the user lands on the signed in app

Examples:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@OnFeatureStart
def hook(context):
init_steps.context_init(context)
init_steps.context_init(context, testSettings)
init_steps.signs_up_process_steps(context, _user, _password)

@OnFeatureEnd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@OnFeatureStart
def hook(context):
init_steps.context_init(context)
init_steps.context_init(context, testSettings)
init_steps.signs_up_process_steps(context, _user, _password)

@OnFeatureEnd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../testSuites/global_shared/"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../src/"))

import steps.startupSteps as common_init_steps
import steps.startupSteps as init_steps
import steps.walletInitSteps as wallet_init_steps

# Global properties for the specific feature
Expand All @@ -14,8 +14,8 @@

@OnFeatureStart
def hook(context):
common_init_steps.context_init(context)
common_init_steps.signs_up_with_seed_phrase_process_steps(context, _seed_phrase, _user, _password)
init_steps.context_init(context, testSettings)
init_steps.signs_up_with_seed_phrase_process_steps(context, _seed_phrase, _user, _password)
wallet_init_steps.activate_and_open_wallet()

@OnFeatureEnd
Expand Down
6 changes: 3 additions & 3 deletions test/ui-test/testSuites/suite_wallet/tst_wallet/bdd_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../testSuites/global_shared/"))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../../src/"))

import steps.startupSteps as common_init_steps
import steps.startupSteps as init_steps
import steps.walletInitSteps as wallet_init_steps

# Global properties for the specific feature
Expand All @@ -13,8 +13,8 @@

@OnFeatureStart
def hook(context):
context_init(context)
common_init_steps.signs_up_process_steps(context, _user, _password)
init_steps.context_init(context, testSettings)
init_steps.signs_up_process_steps(context, _user, _password)
wallet_init_steps.activate_and_open_wallet()

@OnFeatureEnd
Expand Down

0 comments on commit 8e312bd

Please sign in to comment.