Please see How to Modify Squish Functions for an introduction to this topic.
The following example demonstrates an alternative approach to modifying Squish functions which may or may not be a bit easier to understand.
In addition to modifying Squish functions, the example demonstrates counting the number of "fails" and "passes" in the respective variables.
fails = 0
passes = 0
def my_test_fail(msg, detail=''):
global fails
fails += 1
test.fail_org(msg, detail)
def my_test_passes(msg, detail=''):
global passes
passes += 1
test.passes_org(msg, detail)
def my_test_compare(value1, value2, msg=None):
global fails
if not test.compare_org(value1, value2, msg):
fails += 1
return False
return True
def my_test_vp(name, record=None):
global fails
if record is None:
if not test.vp_org(name):
fails += 1
return False
else:
if not test.vp_org(name, record):
fails += 1
return False
return True
def register_test_funcs():
test.fail_org = test.fail
test.fail = my_test_fail
test.passes_org = test.passes
test.passes = my_test_passes
test.compare_org = test.compare
test.compare = my_test_compare
test.vp_org = test.vp
test.vp = my_test_vp
def init():
register_test_funcs()
def main():
startApplication("myapp")
test.fail("fail")
test.fail("fail", "detail")
test.passes("passes")
test.passes("passes", "detail")
test.compare("1", "2")
test.compare("1", "2", "message")
test.vp("VP3")
global fails
global passes
test.log("Fails: " + str(fails))
test.log("Passes: " + str(passes))
Note that one drawback of this approach (and the approach at
How to Modify Squish Functions
) is that a double click on an entry in the Test Results view will open the script file at the line where the original Squish test function gets called - which could be - for example - the third line of the function my_test_passes
.
Related Information