|
|
Re: Repeat the execution of the test cases until terminated manually [message #1802574 is a reply to message #1802525] |
Tue, 12 February 2019 08:06 |
|
Hi Sean,
I would advise against manual intervention during test execution; this sort of slaps the concept of test automation in the face... :)
Would it not be feasible to:
-start a timer of a couple of dozen seconds
-repeat the sequence in question until successful; set verdict to pass
-if above timer expires, set verdict to fail ( to prevent infinite loops)
all this within one test case ; so it's not the test case that has to be cycled but only the relevant code?
Best regards
Elemer
|
|
|
Re: Repeat the execution of the test cases until terminated manually [message #1802586 is a reply to message #1802574] |
Tue, 12 February 2019 10:32 |
|
Hi Sean,
I had a similar demand for repeated test execution and counting the verdicts in an automated fashion. However, I assume stopping the execution on the occurrence of a failed test case should be also easily possible.
Rather than the Eclipse IDE, I used Titan with the CLI and python for the automation tasks.
Let me illustrate the concept with a few snippets of python code:
First, you would require a function which encapsulates the spawning of Titan and your test suite
def start_test_suite(test_suite, config):
"""
test_suite is the path to the binary test suite
config is the path to the configuration file
"""
args = ['ttcn3_start', test_suite, config]
child = subprocess.Popen(args, stdout=subprocess.PIPE)
return child
Now let's start the test suite and check for verdicts
child_process = start_test_suite(test_suite, config)
line = 'initialize line'
while line != '':
line = child_process.stdout.readline().decode("utf-8")
if 'finished. Verdict:' in line:
# here you should have lines like: "MTC@lx: Test case [TC] finished. Verdict: pass reason: [your reason]
# grab the verdict with regex: the verdict result is between the keyword 'Verdict:' and 'reason:'
# e.g. something like matches = re.finditer(r'Verdict:\s(.*)reason:')
Once you have found a fail verdict, you can simply terminate the child process. This should be similar to clicking the "Terminate" button within the IDE
child_process.terminate()
For clean manual termination, you will probably need to add a signal handler which listens for CTRL+C and terminates the child process gracefully.
Cheers,
Alex
|
|
|
Powered by
FUDForum. Page generated in 0.03723 seconds