petek, 11. december 2015

Powershell read jmeter properties files

Powershell give a lot of opportunities how to improve and make better and more automatic jmeter reports before jmeter and and after execution.
 In this blog i will represent you how i read jmeter properties files . These properties can be used later in word documents, sending email, etc...

Jmeter properties files

Property file used in jmeter run:
  • RL_ParallelRuns=1
  • RL_Repetitions=100
  • RL_RampUpPeriod=1
  • RL_TestDurration=30000
Read jmeter properties filein Powershell

Here is part written in powershell how to rad jmeter properties file. Function 'convertfrom-stringddata' is used to parse structured text in property file. Property '-RAW'  define that file is read  as single string.
Here is example how to read jmeter properties file:

      $file = "yourfile.properties"
      $propertiesfile = convertfrom-stringdata (get-content $file -raw)

Once we have a read a file  in '$propertiesfile' now is possible to read parameters by name:

       $JMeterMaxThread= $propertiesfile.'RL_ParallelRuns'
       $JmeterTestDuration=   $propertiesfile.'RL_TestDurration'
       $JmeterRepetitions =   $propertiesfile.'RL_Repetitions'
    
 Parameter 'RL_ParallelRuns' is defined in upper property file and can be reached in simple way just to write name of the varible which read file and property :
      $propertiesfile.'RL_ParallelRuns'


Summary

Powershell contains useful built-in function which simplifies work with files and make big improvements to out automation of test and other stuff.

Ni komentarjev:

Objavite komentar