Declaring variable in a variable

Ask general questions here.
Posts: 1
Joined: Wed Jul 29, 2015 1:46 pm

Declaring variable in a variable

Post by ecardia » Thu Aug 06, 2015 11:40 am

Is it possible to declare a variable in a variable ?

Example :

var1 user
var2 /home/{$var1}/dir

I would like to do this in the "Edit vardiables" menu.



Posts: 107
Joined: Fri Jul 03, 2015 9:18 am

Re: Declaring variable in a variable

Post by jma » Tue Aug 11, 2015 7:19 am

Hi Efisio,

Unfortunately, you cannot create variables dynamically.

I would suggest to implement it in the following way:

1) Add three variables to your recording module
varUser will be combined with varPathPattern. The result will be stored in varPath

2) Create a new user code action which will perform this merge action ( ... tions.html)

3) Implement the method. The String.Format method will replace '{0}' with the variable varUser.

Code: Select all

public void CreateFullPath()
      varPath = String.Format(varPathPattern,varUser);
      Report.Info("Path: "+varPath);
4) Now you should be able to use the path within your data driven test

I hope this solves your issue.
You do not have the required permissions to view the files attached to this post.