diff options
author | Saw-jan <saw.jan.grg3e@gmail.com> | 2022-09-05 14:34:50 +0300 |
---|---|---|
committer | Sawjan Gurung <saw.jan.grg3e@gmail.com> | 2022-09-06 09:28:11 +0300 |
commit | 3ecec27ee51975757fd5c5bff3b5d8efa67943cd (patch) | |
tree | eecd3d842be47ee416e2365809055fa0732127e8 /test | |
parent | 060e380ef8042f9bd0627742c15a5c2455025145 (diff) |
add helper function to determine test pass/fail status
Diffstat (limited to 'test')
-rw-r--r-- | test/gui/shared/scripts/bdd_hooks.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/test/gui/shared/scripts/bdd_hooks.py b/test/gui/shared/scripts/bdd_hooks.py index c120bf0e6..0a42b3b37 100644 --- a/test/gui/shared/scripts/bdd_hooks.py +++ b/test/gui/shared/scripts/bdd_hooks.py @@ -72,7 +72,7 @@ def hook(context): for key, value in context.userData.items(): if value == '': context.userData[key] = cfg.get('DEFAULT', CONFIG_ENV_MAP[key]) - except: + except Exception as err: test.log(str(err)) # Set the default values if empty @@ -139,6 +139,16 @@ def hook(context): ) +# determines if the test scenario failed or not +def scenarioFailed(): + global previousFailResultCount + global previousErrorResultCount + return ( + test.resultCount("fails") - previousFailResultCount > 0 + or test.resultCount("errors") - previousErrorResultCount > 0 + ) + + @OnScenarioEnd def hook(context): # Currently, this workaround is needed because we cannot find out a way to determine the pass/fail status of currently running test scenario. @@ -147,11 +157,7 @@ def hook(context): global previousErrorResultCount # capture a screenshot if there is error or test failure in the current scenario execution - if ( - (test.resultCount("fails") - previousFailResultCount) > 0 - or (test.resultCount("errors") - previousErrorResultCount) > 0 - and os.getenv('CI') - ): + if scenarioFailed() and os.getenv('CI'): import gi @@ -194,7 +200,7 @@ def hook(context): # search coredumps after every test scenario # CI pipeline might fail although all tests are passing coredumps = getCoredumps() - if coredumps: + if scenarioFailed() and coredumps: try: generateStacktrace(context, coredumps) test.log("Stacktrace generated!") |