Pass Variables to SilkTest Workbench stw.exe from Command Line

92 Views Asked by At

Variables are not recognized

I hava a Silk Test Workbench .Net Script called Dummy

Public Module Main
  Public Test As String = "test"
 
  Public Sub Main()
    msgBox(Test)
  End Sub
End Module

I want to run stw.exe using Command Line and override the variable Test:

stw.exe -dsn silktest -username user -password password -script Dummy -variable "Test=hello world"

Following the instruction from the example for using stw.exe.

But the cmd return an error that said the variables are not recognized

The following variables were not passed into 'Dummy' as they are not recognized:
->test

Any wrong from my code? Or is there any way to access the variables from .Net Script by command line?

1

There are 1 best solutions below

2
eggbox On

You need to use a different function prototype for the Main() function that takes the arguments as a dictionary, for example.

Public Module Main
  Public Test As String = "test"

  Public Sub Main(args as IDictionary(Of String, Object)
    Test = args("Test")

    msgBox(Test)
  End Sub
End Module

You also need to add the variable to the script properties, open the script and view the Properties window for the script.

Now right click on the Input node (under the Parameters node) and select Add Input Parameter.... A dialog will appear where you can enter the name of the parameter, select the type of the parameter, and provide a default value.