Page 1 of 1

Test case parameters

Posted: Thu Jun 11, 2015 4:09 pm
by jackrabbit
I have a test case with two parameters called "Param1" and "Param2". I am trying to launch my test case while providing values, as explained in the documentation ( http://www.ranorex.com/support/user-gui ... html#c3022 ) but my parameter is never assigned properly.

Code: Select all

vsphere.exe /tc:MyTestCase /tcpa:MyTestCase:Param1=hello /tcpa:MyTestCase:Param2=byebye
Anyone got this to work on a test case? If possible, I would like to avoid using global variables.

Re: Test case parameters

Posted: Fri Jun 12, 2015 7:36 am
by odklizec
Hi,

It works fine for me? Are you absolutely sure you pass correct test case/parameters names? Also, in case the parameter values contain spaces, don't forget to enclose them in double quotes! BTW, have you tried to simulate your problem with new solution containing just one test case and one recording?

It would be really nice if you could provide some additional details, like your Ranorex version, OS, sample project (if you cannot provide the original one), or at least a screenshot of your test suite structure and data binding dialog for given test case. These details are crucial for understanding and possible solution of your problem.

Re: Test case parameters

Posted: Mon Jun 15, 2015 4:01 pm
by jackrabbit
I am using Ranorex 5.2.3

I created a brand new project with a single Recording "Recording1":
img1.png
img2.png
I run my test with this command in a CMD window:

Bug1.exe /tc :TestCase /tcpa:TestCase:Param1=hello /tcpa:TestCase:Param2=byebye

I get this report with no values for my parameters:
img3.png
Do I need to bind my variables to something in my test when I want to assign a value using the parameter /tcpa ?

Re: Test case parameters

Posted: Mon Jun 15, 2015 4:24 pm
by odklizec
Hi,

Yes, if you want to use TC parameters inside recordings, you must bind them to variables! This is why the test case parameters are not displayed in report log rows. But as you can see in report (Test Case header), both parameters were successfully passed from command line to Test Case. Now you just need to bind them with recording variables.

Re: Test case parameters

Posted: Mon Jun 15, 2015 6:23 pm
by jackrabbit
I must be missing something, I find it difficult to see why I must always bind a parameter to another parameter before I can pass it a value?

Anyway here is what I did in my bindings:
img4.png
When I run my test case, do I have to provide a value to Param# or Variable# ???

I tried both and I still don't see my parameters in the Report action:
img5.png

Re: Test case parameters

Posted: Mon Jun 15, 2015 6:55 pm
by odklizec
OK, if the test case parameters are named Variable1 and Variable2 and test case name is TestCase the command line must look like this...
vsphere.exe /tc:TestCase /tcpa:TestCase:Variable1=hello /tcpa:MyTestCase:Variable2=byebye
I noticed that in your last post, there was used MyTestCase name instead of just TestCase!
Now once these test case parameters are binded to module variables, you should be able to work with them in binded modules. If not, there must be something else wrong? In this case, it would be great if you could post entire sample test suite (zipped without bin/reports folders).

As for binding variables and detailed explanation of data driven approach, I would suggest you to watch this screencast...
http://www.ranorex.com/support/screencasts.html#c3896
and go through the "data driven testing" chapter in Ranorex User Guide...
http://www.ranorex.com/support/user-gui ... sting.html
Feel free to ask if you need some more help ;)

Re: Test case parameters

Posted: Mon Jun 15, 2015 7:08 pm
by krstcs
As a bit of further clarification, variables are objects that hold a value inside a function or method in most languages. So, your variables are the ones that are inside the recording module. Their values may change (hence being variable) during the time that the function or method runs.

Parameters are values that are passed IN to something. In your case, you have command-line parameters that are passed into your testcase parameters. Functions and methods also have parameters, which can be used as variables inside the body of the function/method. This can be confusing, but once you start using them you will understand them better.

Binding is the way of telling Ranorex (or any other data-driven application) what data source goes to what data consumer. Your source is the parameter, your consumer is the recording module, so you have to bind the module's variables to the data source's parameters.

One other thing. It is a good practice to always name your variables and parameters the same thing, if they are going to be used to bind to each other and only each other. Also, name your variables/parameters using something meaningful, not just "var1" or "a". I know in your case you were working on an example, so it's not a big deal, but on a real application (your tests are applications...) you want to make sure that anyone reading the code understands what a variable is for, what it will hold, or what needs to be done with it. For example, use the variable name "UserName" to hold the value of the username that needs to be entered into your system-under-test. Then name the parameter "UserName" as well. One added benefit to doing this is that Ranorex can automatically bind (hint: click Autobind Variables button) variables to parameters with the same name.

Finally, you can bind multiple variables to the same parameter (or data source) if you need to do that. And they can all still use the same names.

Re: Test case parameters

Posted: Wed Jun 17, 2015 7:40 pm
by jackrabbit
Ok, I tried with AutoBind. At first it did nothing, so I realised I has to create my parameters anyway but AutoBind would only bind them by name.

I retested my solution and it works!

Thanks