Ask a Question

Parameter or Variable

SOLVED
ryanterronez
Occasional Contributor

Parameter or Variable

I am fairly new to Testcomplete and QA testing in general.  I am using multiple variables in my tests: tables, passwords, strings...and I am wondering what the difference between a parameter and a variable is and why/when you would select one over the other.

 

Thank you for your time,

 

Ryan

5 REPLIES 5
LinoTadros
Community Hero

Hi Ryan

 

Think of a variable as something you would like to keep around as a value to use or reuse during the execution of your code.  Paramater is something that you would like to pass to another function during the execution.

 

For example:

var x ="Lino";  //That creates a new variable and assigns it the value of "Lino" in order for you to use that value whenever you want to.  

var x = foo( ); //here you are calling a function called foo that returns a value and you are saving that value to the variable X.

 

function foo( url ) { } //here url is a parameter, that means that function foo can not be called unless you pass a value to the function as a parameter.  So later on, in another function, i can call it by saying:

foo( "http://www.smartbear.com");

//here the function foo will be called passing a parameter of the value of the url you want to use.

 

Hope that makes sense.

Cheers

-Lino

ryanterronez
Occasional Contributor

Lino,

 

Thanks, that makes perfect sense to me.  Also, I love the training videos that you did with Smartbear Academy.  I use them a lot when I get stuck.

 

Ryan

Thanks Ryan!

tristaanogre
Esteemed Contributor

While you are not restricted to using JavaScript in TestComplete, in addition to @LinoTadros and his immensely helpful information (I learned a lot from him as well, back in the day) might I suggest engaging in an online tutorial for learning coding?  Check out https://www.w3schools.com/js/default.asp

 

While you aren't going to be writing application level code, something like this is helpful for the following reasons:

 

1) Learning how code works and is written and is built makes you a better tester over all as it will help you better understand how the application works and, therefore, how best to test things.

2) Even if you write only Keyword based tests in the visual editor, you will still need to understand things like variables, parameters, data types, if-then, loops, etc.  Programming logic is part of any good automated test because there will always be conditions that you'll need to write logic to account for

3) While keyword tests in TestComplete have come a long way, I still find that sometimes the most elegant way to perform certain tasks and checks is in code and not in keyword tests.  You will, eventually, find yourself needing to write something that will be easier to do in script code.

 

Happy testing!


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
ryanterronez
Occasional Contributor

@tristaanogre 

Thanks for the info.  I have been doing a lot more scripting using JavaScript for my tests; I find that there is a certain level of flexibility attained using scripts that you just cannot easily match on the keyword side.  I have already implemented this new knowledge of parameters in my tests and that has made them easier to read and less cluttered.

 

Thanks for the response!

cancel
Showing results for 
Search instead for 
Did you mean: