2

I am running a script through testrunner CLI through a Jenkins build. I want the result's saved to a new folder for each run. How do i do it?

testrunner.bat -r -j -J "-fC:\Users\xxxxxx\Desktop\Reports\xxx\xxx" "-RProject Report" "-EDefault environment" -I "C:\TCOE\Automated_Smoke_and_Regression_SoapUI_Tests\xxx\xxx_PRODUCTION-soapui-project.xml"

Right now the script looks like the above pasted one. Where I declare the root location for the report explicitly.

What do I do to ensure each run saves the report in a new location?

Do I do it through Jenkins or SOAPUI? What is the best approach?

Thanks Sandip

Rao
  • 20,781
  • 11
  • 57
  • 77
Sandip Das
  • 35
  • 9
  • Are you using Ready API? Do you use junit style reports? Is reports overwrite each time currently? Please update the question with these information. – Rao Nov 09 '16 at 17:17
  • Are you using Ready API? - Yes; Do you use junit style reports? - Yes; Is reports overwrite each time currently? - Yes they do. So, you understand my predicament. I want to save each & every report.; – Sandip Das Nov 09 '16 at 17:22
  • How are you calling the above command (mentioned the question) in jenkins? By the way thanks for your previous answers. And what kind of job you configured in jenkins? – Rao Nov 09 '16 at 17:26
  • Thanks for your quick response. Ans: By adding a build (windows batch) step and adding the above command in it. I thought it'll be easier to schedule than trying to do it in a desktop batch script. I'm finding my way through Jenkins & trying to refind my way with SOAPUI. Please help! – Sandip Das Nov 09 '16 at 17:31
  • If you want to wrap that command into a batch file, then it would be easy to assign a new directory name each time based on date. You can give it a shot, then you can directly call that script in jenkins as well if you want. – Rao Nov 09 '16 at 17:50
  • Are you suggesting making it into a service? Could you please elaborate? Thank you for response. – Sandip Das Nov 09 '16 at 17:59
  • Let me rephrase the question? Through CLI how do I ensure Reports aren't overwritten and saved to a new location for every subsequent run? – Sandip Das Nov 10 '16 at 06:54
  • Sandip, have you got chance to try the solution provided in the answer? – Rao Nov 11 '16 at 06:33
  • Hi Rao,I'm going to try it now. I'll keep you posted. – Sandip Das Nov 11 '16 at 10:36

1 Answers1

2

Here is windows batch file which would allow you set the dynamic directory using date time for the result to be captured without over writing the previous results.

Of course, you may call batch file from Jeninks as well.

copy the below script to a file say, wrapper_testrunner.cmd and place this file where testrunner.bat is located. Because it is call soapui's testrunner.bat file, i.e., place this batch file under SOAPUI_HOME/bin directory.

@echo off

REM Provide the base directory where the results needs to be saved
REM A new dynamic directory is created using date time under this directory
set RESULTS_BASE_DIR=C:\Temp\TEST_Results

REM Set the soapui project to run 
set PROJECT=C:\Temp\Project\hellow-world-soapui-project.xml

REM Set the environment name
set ENVIRONMENT_NAME="Default environment"

REM set the dynamic directory name using date time
set mdate=%date:~10%%date:~4,2%%date:~7,2%%time:~0,2%%time:~3,2%


REM create dynamic directory for results
mkdir %RESULTS_BASE_DIR%\%mdate%

REM run the project using testrunner
call testrunner.bat -f %RESULTS_BASE_DIR%\%mdate% -E %ENVIRONMENT_NAME% -raj %PROJECT%

If you needed to change any value of the variable, feel free to change, I just put the place holders only.

Having said, that you also add any additional options required to be passed to testrunner.bat file.

Hope this is helpful.

Rao
  • 20,781
  • 11
  • 57
  • 77