0

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?

Raymond
  • 1
  • 1
  • Please include the information by editing your question. Links to external resources are liable to become invalid rendering your question unusable for future readers. Relevant code & sample test data should be inserted in plain text, obfuscating sensitive data if required. – Magoo Jan 20 '23 at 07:31
  • @Magoo Already edited. – Raymond Jan 20 '23 at 08:41

1 Answers1

0

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.

eggbox
  • 617
  • 4
  • 16