Best way to reference external test files?
Posted: Mon Feb 03, 2014 7:45 pm
Say your AUT needs to access a file (i.e. an image file to upload into a system and change a header, or a text document to attach to an email, etc.), what would you say is the best way about doing this?
The code I've been using is:
Which will reference the bin/Debug folder. I'll then store a TestFiles folder in the project's folder and use general code that moves up two folders in the directory to access the project directory, and then access the TestFiles folder from there (have I lost you yet?).
So far this has worked very well when running via Ranorex Studio. However...
I have some tests that I run from command line, and the System.IO.Directory.GetCurrentDirectory() code will reference the folder where the .bat file is located, not where the .exe being run is located.
I could go through each test suite and add a condition to check if the current directory is the bin/Debug folder, but I feel like it's a little clunky. Has anyone else reference test files like this and have a more efficient way of doing so?
The code I've been using is:
Code: Select all
System.IO.Directory.GetCurrentDirectory()
So far this has worked very well when running via Ranorex Studio. However...
I have some tests that I run from command line, and the System.IO.Directory.GetCurrentDirectory() code will reference the folder where the .bat file is located, not where the .exe being run is located.
I could go through each test suite and add a condition to check if the current directory is the bin/Debug folder, but I feel like it's a little clunky. Has anyone else reference test files like this and have a more efficient way of doing so?