Why when I set the remote machine name using the -m switch from the command line does SilkTest connect to the local machine?
Remote Testing from the Command Line:
Firstly, check out the Command Line section in SilkTest help which details all the options that can be run from the command line.
You can use the -m switch to connect to a remote machine (Agent).
However the -m switch becomes irrelevant if you are using a project and/or option set as well.
What does this mean?
- Once the -m switch has set the Agent Name, if you then open a .vtp file SilkTest will then load the relevant project settings stored in the project"s .ini file which includes the agent name.
- If you use the -m switch to set the agent name and then load a .opt file, SilkTest will then load the relevant option set settings which include the agent name.
- General manual SilkTest behaviour decrees that the last file opened will take precedence so, if you open an opt file and then a vtp file, then the vtp setting take precedence. If you open a project and then open an opt file within it, then the opt file settings will be employed for as long as the opt file remains loaded (once opt file is closed/unloaded, the projects own setting will then be used)
The above command line will:
- Load up SilkTest:
- Sets the remote machine TestMachine2:
- Opens the project RemoteTest.vtp:
- Runs the Test Plan BrowserTestPlan.pln:
Behaviour of Example 1:
What actually happens?
- 1. Partner.exe (SilkTest) is launched
- 2. TestMachine2 is set as the remote Agent
- 3. RemoteTest.vtp project is opened (project settings are now loaded and take precedence (thereby resetting Agent Name)
- 4. BrowserTestPlan.pln test plan is run
The usefulness of setting the remote agent via the -m switch comes down to the order in which the settings take precedence.
The order of precedence for settings is:
- 1. Project
- 2. Option Set
- 3. Command Line
This precedence will come down to the order in which events take place as illustrated in the 4 steps above (-m agent name will be set first, then -opt options set loaded, then -proj project loaded).
Therefore when a project is opened, its settings will take precedence over any settings in the option set (which was open prior to the project) or command line. Likewise the option sets settings will take precedence over the command line.
From the above example then, the remote agent will be set as TestMachine2 by the -m switch, but it will then be changed to whatever Agent Name is set in the RemoteTest.vtp project. Therefore the test plan BrowserTestPlan.pln will be run on whatever Agent is stated in the RemoteTest.vtp project.
This example runs SilkTest, sets remote machine and then runs the Test Plan. As there is no project being opened or option set being loaded the test plan will run on the remote agent "TestMachine2".
Note: in order to do this you must make sure that all projects and option sets are closed before closing SilkTest, otherwise they get automatically loaded upon opening SilkTest.
Finally, you will need to decide how you want to work, if it is more important for you to
A. Use the -m switch via the command line
Then you will be unable to use project files or option sets.
Both a project or opt file will contain important settings and configuration which help your tesplan or script run. You will need to ensure that your testplan or script is capable of running without this information, therefore you will need to make sure things like extensions are set properly, files needed by the tests are correctly referenced etc... so that it can run without the use of either a project or option set.
B. Use your project
In which case, your handiest solution would be to set the Agent Name inside the Runtime Options of the project. This way, every-time you open your project it will be set-up to run remotely on a specific machine, which you can manually edit at any time if you wish to run on a different remote machine.
Therefore, from the command line, you would simply leave out the -m switch and the name of the remote machine, choosing instead to call your .vtp file (which already held the relevant connection information)
Option B would be more preferable as it is the most robust method.