Sign-up our Newsletter  Register on our LinkedIn  Follow us on Twitter  Check out our Facebook  Follow us on Google+

Use params in a test case example to test remote port and REST API

In this article, you get an example on how to use the Params of Test Case.

  • how to use the Params in a Testcase
  • how these params are passed to the test script 
  • How a script can use them
  • How the results and a log file from the test case can be uploaded back to XStudio


For this example:

  • we use simple scripts in '.Bat' (for windows). 
  • the script is able to parse any number of arguments
  • then it launches a tool in a command line (taking advantage of the params)
  • throughout the script we log information in a 'log.txt' file
  • at the end of the script, we exit with 0 as an error code if the action succeeded, something else if it failed
  • the launcher then return all information to XStudio DB (success/failure, messages,  and uploaded 'log.txt' file)

so you get a result like the following one:


Note: the launcher we use in this example is a derivation the standard 'bat.jar' launcher. It has been tested to work with XStudio 3.1. A version for 3.0 can be tried (see as attachment of this article) - for the moment let's call it "bat_with_params.jar"


We used the same script to enable 2 differents tests:

  • TestTCPportAvailability: ensures that a MYsql database is reachable of  a remote server (we use PORTQRYV2 for that)
  • TestCurlXstudioGetinfo : Query the XStudio 'GetInfo' REST API on a remote XStudio server (we use CURl for this)


Note: if you want to redo this you need to download the PortQryV2 Microsoft Tool, and the cURL tool



1  TestTCPportAvailability

  1. Create a category that uses the bat_with_params.jar launcher
  2. In that category create a test that you name "TestTCPportAvailability" - the test name must match the name of the script
  3. For that test create a test case, with any name that suits you
  4. For that test case, create and then associate 2 params 'ipadress' and 'port'
  5. Value the ipadress with the address of your XStudio server (in this example
  6. Value the port with the DB port you use ( in this example 3306 for MYsql, but that can anything that matches your environment)
  7. Place the TestTCPportAvailability.bat in a folder you want - note the folder path for later
  8. Start running the test  (the green start button ) when you click on the test
  9. It will request you for a configuration. Create a new one with the follwoing information
    • the root path  being the folder where you placed the TestTCPportAvailability.bat
    • Leave 'Synchronous' as the mode to run the test
    • Leave 600 s at the timùeout (this is only used when you run you test asynchronously)



  1. Xstudio starts the launcher bat_with_params.jar
  2. This one starts the test (it calls the TestTCPportAvailability.bat) and passes to it the first test case with the following command line arguments , inncluding the params you have set

TestTCPportAvailability /debug /testcaseIndex=1 /ipadress= /port=3306

Note: in your envrionment '' would be replaced by the value you entered in the param 'ipadress' in XStudio and '3306' would be replaced by the value you entered  for the param 'port'


The TestTCPportAvailability script gets the arguments and their values; it will jut run the command 

PortQryV2 -n -e 3306 -q >>log.txt

Anything that it being done will be gathered in the log.txt

Then it treats the return code and exit base on failure or success


The launcher then gets the return code from TestTCPportAvailability.bat, and:

  • Declare success if the code is 0  or failure if else
  • Search for the log.txt and parse it for infrmation to use as messages
  • Upload the log.txt file as an attachment to the test case result
  • Load all information back to XStudio DB


In XStudio, you should now be placed on the result of the session (created automatically for you in the Campaign Playground Folder)



  1. Look into the result tab; choose the 'tree view'
  2. You will see the test as 'succeed' or 'failed' (based you set up)
  3. Click on the test case you will see:


  • the message that were  provided by the launcher

  • the attachments - you should have the 'log.txt' file. open it  you see something such as the following:


/debug /testcaseIndex=10 /ipadress= /port=3306
The value of /ipaddress is:
The value of /port is: 3306

Querying target system called:

Attempting to resolve IP address to a name...

Failed to resolve IP address to name


TCP port 3306 (unknown service): LISTENING
Port is listening


Summary: you have used 2 params, valued them, passed them to a script that used them to issue a command line tool, got the return code and uploaded a file as result of that test.



2 TestCurlXstudioGetInfo

This is extremely similar - but in that case, it uses Curl rather than PortQryV2. Curl allows, among other things, to query a rest API.

In this example, we hard coded the service that is being queried (XStudio Getinfo).

For this service call, we just need the 'ipadress' params; but you can imagine passing any number of params for other API service call


You can upload the .bat scripts as examples. 

Note: beware that these are for example only and are not supported by XQual). 


You can also upload the bat_with_params.jar launcher and its XML (should work for 3.0; not for 3.1)

  • On the standalone Windows version you just copy them in <xstudio install folder >\bin\launchers 
  • On the VM or server you need to copy them on <xstudio install folder >\bin\launchers and add a line declared this new launcher in the 'launchers.xml' file








Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.