Forum Discussion
IBM_-_PA_Suppor
10 years agoOccasional Contributor
I think I finally figured out why I was getting an empty string when calling the GroovyUtils.projectPath on the command-line. This was after doing a bit of digging around but I think I learned something that hopefully should be useful to the community. IMHO a JIRA should be raised to handle the exception thrown by the code that follows.
The code for the GroovyUtils.getProjectPath() method reads like this:
when I am running this within SOAPUI I get the following path being logged:
C:\Users\....\<project.xml>
but when I run it on the commandline it is reading the path to the project xml from my pom.xml (since I am not using the default).
The code above puked with an java.lang.StringIndexOutOfBoundsException- which obviously was not caught (the code does a check for -1 but does not do anything else) and hence I was seeing the blank result returned.
However, I updated the pom to read like this:
and that returned the results I wanted.
So if you ever have the requirement of running your tests on jenkins (our jenkins master slaves are all linux based) you don't have to worry about it not working!
Hope that helps!
The code for the GroovyUtils.getProjectPath() method reads like this:
Project project = ModelSupport.getModelItemProject( context.getModelItem() )
String path = project.getPath()
int ix = path.lastIndexOf( File.separatorChar.toString() )
log.path ==> this is my code
.....(some more code that isn't important to this discussion)
when I am running this within SOAPUI I get the following path being logged:
C:\Users\....\<project.xml>
but when I run it on the commandline it is reading the path to the project xml from my pom.xml (since I am not using the default).
<configuration>
<projectFile>./testScripts/project.xml</projectFile>
The code above puked with an java.lang.StringIndexOutOfBoundsException- which obviously was not caught (the code does a check for -1 but does not do anything else) and hence I was seeing the blank result returned.
However, I updated the pom to read like this:
<configuration>
<projectFile>.${file.separator}testScripts${file.separator}project.xml</projectFile>
and that returned the results I wanted.
So if you ever have the requirement of running your tests on jenkins (our jenkins master slaves are all linux based) you don't have to worry about it not working!
Hope that helps!
Related Content
- 3 years agogroovyguy