|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
|| Alexander Kaiser
Registered: May 2017
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)
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
For clean manual termination, you will probably need to add a signal handler which listens for CTRL+C and terminates the child process gracefully.
Powered by FUDForum
. Page generated in 0.01322 seconds