1

I have a test suite that links to a csv file stored on my local machine to check that certain values/string are as expected when I run tests. I am using Selenium(java) that I have linked with maven to run in a Jenkins build. I have written a method to read in the csv as a 2D array. This works fine with the file path /home/usr/location

However I need to place the csv file on many VMs to test production environments. When I try to change to a relative path such as ~/location I get a file not found error.

I have all the correct permissions

Daniel Cohen
  • 301
  • 1
  • 4
  • 14
  • Don't you want to put the file with Selenium project then if you need to share them across different machines? – Saifur May 31 '15 at 09:28

1 Answers1

2

I'd suggest to keep the CSV file with the build, and on the classpath (e.g. src/test/resources/csv/) or whatever. Then you should be able to look up the csv file from the classpath.

Or if you need a separate path, then e.g. src/test/csv should suffice. In this case you should be able to look up the path using something like ./src/test/csv (as the working directory for a maven build is the project directory).

If you would really want to use the user's home directory, then you could go with the System properties, looking up user.home, however then please be aware of the possible issues described more here

Alternatively, you could use some kind of environment (or application-managed) property, to make the CSV file located from somewhere on the file system, where you could configure it based on the actual environment. I mean something like starting the application or tests with -Dcsv.location=/proper/location/data.csv.

Community
  • 1
  • 1