A geb test tests file upload in a grails application. According to the documentation the absolute path of the file has to be specified in the test. Is it possible to make the test a bit more portable between developers/machines by including a file in the grails source tree and then getting its absolute path from the geb test?
Asked
Active
Viewed 1,035 times
3 Answers
0
You may be interested in doing something like this
http://www.mkyong.com/java/how-to-get-the-filepath-of-a-file-in-java/
In the Get file path example he creates a temporal file and then gets its filePath. If you need a specific file then I recomend you to build / write on it after creating it, this way you have a User/enviroment free file to access from your app anytime.
I ran into a problem like this once, uploading a photo to a server with grails, and for test or repetitive actions I created it and added the base64 code on runtime.
Hope it helps. Good luck! :)

reixa
- 6,903
- 6
- 49
- 68
0
I just ended up using System.properties['base.dir']
to get real path to my application.

zoran119
- 10,657
- 12
- 46
- 88
0
String cd = new File(".").getAbsolutePath().replace(".","");
String file = cd + "file.jpg"
println file
It's work for me, on windows an linux. it's need for CI and local building test.

plsgogame
- 1,334
- 15
- 28