saurabhsharma09
11 years agoContributor
[R]How to read files in directory present under project root
Hello,
I have multiple files inside a folder "attachments" which is present under project directory.
I have to read each file one by one, attach it to the REST service and send as attachment.
I've selected "Resource root" as ${projectDir} and trying to create url to read files in a Groovy test Step.
Through groovy in eclipse i am able to read files successfully however in soap ui i am not able to do so as Soap UI is searching the folder inside it's Installation directory instead of project directory
Below is groovy code snippet which i am using in eclipse:-
def url="E:\\Document_Service\\attachments"
new File(url).eachFile{file ->
if(file.exists()){
println(file.name)
}
}
I've tried to create url and substitute it in the code above but i think i am doing something wrong.
def projectroot = context.expand('${projectDir}')
def url ="${projectroot}\\attachments"
I've added screenshot for my directory structure also.
Could you please point me to the correct direction?
Thanks,
Saurabh
I have multiple files inside a folder "attachments" which is present under project directory.
I have to read each file one by one, attach it to the REST service and send as attachment.
I've selected "Resource root" as ${projectDir} and trying to create url to read files in a Groovy test Step.
Through groovy in eclipse i am able to read files successfully however in soap ui i am not able to do so as Soap UI is searching the folder inside it's Installation directory instead of project directory
Below is groovy code snippet which i am using in eclipse:-
def url="E:\\Document_Service\\attachments"
new File(url).eachFile{file ->
if(file.exists()){
println(file.name)
}
}
I've tried to create url and substitute it in the code above but i think i am doing something wrong.
def projectroot = context.expand('${projectDir}')
def url ="${projectroot}\\attachments"
I've added screenshot for my directory structure also.
Could you please point me to the correct direction?
Thanks,
Saurabh