Forum Discussion

djangofan's avatar
djangofan
Contributor
13 years ago

The first line of testrunner.bat needs to change

I am a SoapUI PRO subscriber. I think it is unfortunate that the first line of "testrunner.bat" is:

set SOAPUI_HOME=%~dp0


For multiple reasons:

1. Because of this, the testrunner uses an invalid SOAPUI_HOME value, which includes the "/bin" directory on the end of the defined variable. Everyone knows that the "/bin" directory should be a subdirectory of the actual SOAPUI_HOME instead of being part of it. Because of this, to reference anything outside of the "bin" directory, you have to use "%SOAPUI_HOME%\..\lib" or similar, which is ugly.

2. Using set SOAPUI_HOME=%CD% would have been better than set SOAPUI_HOME=%~dp0 because the %CD% doesn't have a backslash on the end. Without stripping of the trailing slash, this also makes things ugly because, for example, calling testrunner.bat currently looks like this:
CALL "%SOAPUI_HOME%testrunner.bat"
instead of the much prettier alternative:
CALL "%SOAPUI_HOME%\bin\testrunner.bat"

This is also ugly and unfortunate that the script is this way.

3. It is really too bad that the first line doesn't look like this instead because it would allow setting SOAPUI_HOME in a system variable or in a calling script without having to worry about the testrunner.bat script stomping all over the variable value:
IF NOT DEFINED SOAPUI_HOME SET "SOAPUI_HOME=%CD%"


To properly determine SOAPUI_HOME, I would use this code snippet:


:: Set SOAPUI_HOME var based on parent folder and
:: make sure it doesn't end with the 'bin' directory or a slash
IF NOT DEFINED SOAPUI_HOME (
SET "SOAPUI_HOME=%CD%"
)
IF "%SOAPUI_HOME:~-1%"=="\" SET "SOAPUI_HOME=%SOAPUI_HOME:~0,-1%"
IF "%SOAPUI_HOME:~-3%"=="bin" SET "SOAPUI_HOME=%SOAPUI_HOME:~0,-3%"
SET "PATH=%PATH%;%SOAPUI_HOME%\bin"

7 Replies

  • nmrao's avatar
    nmrao
    Icon for Champion Level 1 rankChampion Level 1
    Yes, few days back it was posted (viewtopic.php?f=13&t=19518) about soapui.bat regarding the same.
    Thank you for pointing this as well. In fact, all the batch files are done in this way, it seems.

    An additional change would be needed in CLASSPATH to the code snippet added in the post (if some one uses the suggested change, assuming soapui-4.5.2 is being used).

    original
    set CLASSPATH=%SOAPUI_HOME%soapui-4.5.2.jar;%SOAPUI_HOME%..\lib\*;


    change
    set CLASSPATH=%SOAPUI_HOME%\bin\soapui-4.5.2.jar;%SOAPUI_HOME%\lib\*;
  • nmrao's avatar
    nmrao
    Icon for Champion Level 1 rankChampion Level 1
    Amendment to earlier post:
    Original
    if exist "%SOAPUI_HOME%..\jre\bin" goto SET_BUNDLED_JAVA


    Change
    if exist "%SOAPUI_HOME%\jre\bin" goto SET_BUNDLED_JAVA


    Original
    set JAVA_OPTS=-Xms128m -Xmx1024m -Dsoapui.properties=soapui.properties "-Dsoapui.home=%SOAPUI_HOME%\"


    Change
    set JAVA_OPTS=-Xms128m -Xmx1024m -Dsoapui.properties=soapui.properties "-Dsoapui.home=%SOAPUI_HOME%\bin"

    having some problem if -Dsoapui.home is present/passed, testrunner did not run. after removing this argument it worked.
    Original
    set JAVA=%SOAPUI_HOME%..\jre\bin\java


    Change
    set JAVA=%SOAPUI_HOME%\jre\bin\java


    Original
    if "%SOAPUI_HOME%\" == "" goto START
    set JAVA_OPTS=%JAVA_OPTS% -Dsoapui.ext.libraries="%SOAPUI_HOME%ext"
    set JAVA_OPTS=%JAVA_OPTS% -Dsoapui.ext.listeners="%SOAPUI_HOME%listeners"
    set JAVA_OPTS=%JAVA_OPTS% -Dsoapui.ext.actions="%SOAPUI_HOME%actions"


    Change:
    if "%SOAPUI_HOME%\" == "" goto START
    set JAVA_OPTS=%JAVA_OPTS% -Dsoapui.ext.libraries="%SOAPUI_HOME%\bin\ext"
    set JAVA_OPTS=%JAVA_OPTS% -Dsoapui.ext.listeners="%SOAPUI_HOME%\bin\listeners"
    set JAVA_OPTS=%JAVA_OPTS% -Dsoapui.ext.actions="%SOAPUI_HOME%\bin\actions"


    Looks like, more changes? may it would be better to upload the file itself.
  • Yes, it does seem that all the scripts need to be reworked and possibly merged into one master script.
  • nmrao's avatar
    nmrao
    Icon for Champion Level 1 rankChampion Level 1
    I am not really sure when you say master, what is the repository? I can help fixing all the bat files.
  • nmrao's avatar
    nmrao
    Icon for Champion Level 1 rankChampion Level 1
    Thank you redfish4ktc.

    I am new to git. Going to thru the manual to understand how git works. If there is any reference doc available for quick start to start with soapui git repo, i would be glad to go over.
    Did the folloiwng.
    Opened the link you send.
    Clicked on fork to https://github/nmrao/soapui
    Then run the command on my local machine - git clone https://github/nmrao/soapui
    Am i in the right direction?
  • redfish4ktc2's avatar
    redfish4ktc2
    Super Contributor
    nmrao you are in the good direction with git :-)

    about the link to the PR I provided, it explains what djangofan means by "one master script": a script with all the logic that can be called with option to run different soapui class (soapui gui, testrunner, mock, ...)