i474
i474

Reputation: 654

JMeter saving test results into file. CLI

I added 'Simple Data Writer' to my test plan with the next filename path:

${__time(Y-MM-dd)}/${__time(HH-mm)}.jtl

It works perfectly when I run script from UI but not from command line (script doesn't create folder and saves results into incorrectly named file).

Any ideas how to create folder with date in the name and time in name of .jtl file using Simple Data Writer ?

I'm using windows 10.

Thank you

Upvotes: 0

Views: 486

Answers (2)

i474
i474

Reputation: 654

For some reason when running from cli on windows, jmeter doesn't adapt file separators for current os. This solution works for me:

${__time(Y-MM-dd)}\\${__time(HH-mm)}.jtl

Upvotes: 0

Dmitri T
Dmitri T

Reputation: 168002

  1. Define results file location using __P() function like:

    ${__P(date,)}/${__P(time,)}.jtl
    

    JMeter Property in listener names

  2. Create a batch file to run your JMeter script which will define these date and time properties using current system date and time via -J command line argument. Example code (you might need to amend it to correspond your operating system regional settings like short date format)

    @echo off
    For /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set testdate=%%c-%%b-%%a)
    For /f "tokens=1-2 delims=/:/ " %%a in ('time /t') do (set testtime=%%a-%%b)
    jmeter.bat -Jdate=%testdate% -Jtime=%testtime% -n -t test.jmx
    
  3. Run JMeter test using above batch file - the listener should create the relevant folder and .jtl results file.

See Apache JMeter Properties Customization Guide to learn more about JMeter properties and ways of setting, reading and overriding them.

Upvotes: 1

Related Questions