Blogs:

Relative Paths for Visual Studio Generic Tests

Mark

October 20, 2013 / No Comment

To make generic tests robust enough to run for all developers on your team and on the build server, you are likely going to want to avoid hard coding the path to the executable.  To do this successfully, you need to have a list of all the environment variables that are available when the test executes.  These can be obtained by creating a generic test with the existing program as %COMSPEC% (the fully pathed location for cmd.exe) and setting “/C set” as the Commnd-line arguments.  The result, with all standard environment variables pulled out, is as follows:

Where I have substituted the following values:

Of these, the most important in my experience is %TestLocation% as this identifies the directory of the test project, and therefore, you can find relative directories from that.  For example, if you want to find a file located in the nuget packages directory you would use

AUTHOR: CATEGORY: .Net, ALM, Blog, C#, Visual Studio

Leave a Reply


Contact Us
Email: info@IntelliTect.com
Phone: (509) 315-3400




Testimonials

Great organization to speed through the material. I was aware of much of the material already, but the detail on Generics was FANTASTIC. I will be looking into Mark's book and blog!
- Seminar Attendee, TechEd 2011, Atlanta, GA
CONTACT US: (509) 315-3400 | Info@IntelliTect.com | Jobs | Site Map