velvad avatar image
velvad asked velvad posted

Scripting Logic



I am new to Fanfare but i do have exposure on scripting using TCL. I feel TCL is flexible as I can acheive anything I want using the if-else since i can insert it wherever I want. But since I am not familiar with the iTest interpreter I am finding it difficult if i apply the same logic which i use in TCL interpreter in itest.


Following are some examples:


Example 1:


While using the Analysis rules I can use an assert processor and based on the Value i can do an action. There are several actions such as AbortExecution, AbortStep, CallProcedure etc


Say I use CallProcedure and call a procedure and now if i need to check the return value of this procedure and then again want to call a procdure, how do i do?


Below if the assert:


if $value == 1


CallProcedure <Procedure Name>  <---------------------- How do i check the return value of this Procedure and then call another procedure based on the return value.


Example 2:


I can see a command readFile which is used to read the contents of the file. Genereally in TCL what we do is:




if {[file exists .....]} {

open ....

and then read





if {![catch [open file]} {

read the contents of the file





if i directly use readFile and if there is no file present then this step is going to error out. Is there a way that I can use a catch statement or something where I do not want to proceed with the subsequent steps in the procedure if the first step which is readFile errors out. How do i implement this Fanfare testcase?


Please give me some inputs for both these Examples and also please do share any advanced scripting techniques or best practises that some might have come up with so that i can get an idea of how the commands are being implemeted in the fanafare testcases.






10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

KumarS avatar image
KumarS answered KumarS posted

iTest interpreter is as powerful as a tcl interpreter in its abilities and flexibility. What you are talking about now is "general purpose" programming flow. Analysis rules are designed to give users a really quick way to analyze data without doing letting the "programming" getting in the way. In your case, you want to do something more generic which sometimes means that analysis rules are not suitable for. Remember that anything you can do in analysis rules, you can do it in iTest steps.


In this case, you have two options:

1. The procedure you call does everything i.e. calls the other procedure, gets its return value and processes the complete data so that top level analysis rule looks as simple as call this procedure.

2. Do not use analysis rule right on the step. You can store the extracted data into a variable and then on the next step, use "if" statement to evaluate the same expression you would have in the analysis rule. Now you can do whatever you want by calling procedure, getting its return value and processing it just like you would do in tcl.


10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.