Custom template matching mechanisms

27 views
Skip to first unread message

quen...@gmail.com

unread,
Jun 28, 2013, 11:02:15 AM6/28/13
to testerm...@googlegroups.com
Hello,
Firstly, nice job, Testerman is a good software.
I've got an idea to improve Testerman. I use template matching in Testerman to detect if i receive precise data. It's a good concept but sometimes, i can't use basic matching mechanisms because i want to check complex data, like compare two dates. If we could develop our own matching mechanisms, that would be so cool. Currently, after i used the template matching, i must use a function to seek into my data for get my data and compare it. It's not optimized, but it's the only solution i found currently.

Sébastien Lefèvre

unread,
Jun 28, 2013, 1:43:51 PM6/28/13
to testerm...@googlegroups.com
Hello,

This may not be a definite answer to your problem, but you currently have the possibility to transform your received message on the fly before matching it with a template. This is done via the with_() function that does not necessarily takes a codec identifier as a first argument, but can accept any callable() (a function) to transform the incoming data first.

Something like that:

class TC_TEST(TestCase):
def body(self, **kwargs):
message = "2013-06-12"
template = with_(lambda x: x.replace("-", ""), "20130612")
if match(message, template):
setverdict(PASS)
else:
setverdict(FAIL)

TC_TEST().execute()


In the template, the with_(lambda x: x.replace("-", ""), "20130612") first purges the '-' in the incoming messages before checking the value.

You may create a more complex function to transform multiple date formats into a single "reference" one that would be used for matching:

def my_function_to_convert_dates(d):
  # always return a date as a (float) timestamp
  # ...

...  
template = with_(my_function_to_convert_date, 123456789.12)


---

Alternatively, you can create your own matching objects by modifying the TestermanTTCN3.py code.
In that case, you should create your own CustomTestermanTTCN3.py by copy (for instance), then on server side in conf/language-apis.conf create new lines from the existing *.1 entries:

testerman.te.python.module.api.2 = CustomTestermanTTCN3
testerman.te.python.dependencies.api.2 = <the same as for api.1, replace TestermanTTCN3.py with CustomTestermanTTCN3.py>

This create a new "TTCN3 provider" entry whose ID is 2.

Then, in your ATS, from QTesterman, check the "ATS properties" and change the language API to 2 to use your custom modules.

This way, you can alter the TTCN3 implementation on will without impacting the "official" Testerman API. 

Since you won't inherit from the "official" addons and fixes, the first approach, if applicable in your case, should be better.

thanks,
-seb






 






2013/6/28 <quen...@gmail.com>
Hello,
Firstly, nice job, Testerman is a good software.
I've got an idea to improve Testerman. I use template matching in Testerman to detect if i receive precise data. It's a good concept but sometimes, i can't use basic matching mechanisms because i want to check complex data, like compare two dates. If we could develop our own matching mechanisms, that would be so cool. Currently, after i used the template matching, i must use a function to seek into my data for get my data and compare it. It's not optimized, but it's the only solution i found currently.

--
You received this message because you are subscribed to the Google Groups "Testerman Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testerman-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Sebastien Lefevre
seb.l...@gmail.com
Reply all
Reply to author
Forward
0 new messages