locked
Generic Unit Test Environment Variables RRS feed

  • General discussion

  • I have a generic unit test that runs as part of an automated build. The issue I'm having has to do with paths to extra files, to files produced from the build, etc.

    Generic unit tests have environment variables, but they are not documented anywhere I could find. The only relevant document I found is this: http://msdn.microsoft.com/en-us/library/ms404706.aspx

    Maybe I missed something, but the Googles and Bings of the world couldn't find it for me. In addition, running these tests from a TFS build makes it even more tricky, since there's no real option of hardcoding the paths at all (or at least, one shouldn't). So to end the madness, I made a console application that spits out all the environment variables it can see, and ran it through a TFS build to see... and I finally got my list. Now that I can search on the variable's name I did find a blog post from some guy that gives you the list, which is more complete than mine because I only looked at stuff prefixed with "TEST".

    http://intellitect.com/relative-paths-for-visual-studio-generic-tests/

    What I was most interested in was %TestLocation% because at least during a team foundation server 2013 build, you can use that with ../src to get to the source directory (in case you need any extra files that are being pulled from the source tree). Hopefully someone finds this useful and hopefully I've used better keywords so this page can be indexed by search engines better. And for the record, here's the variables and their values I pulled out (during a TFS build, on TFS 2013):


    TestDeploymentDir : C:\Builds\<agent number>\<project>\<build definition>\TestResults\<excuting user>_<machine name> <timestamp>\Out
    TestDir : C:\Builds\<agent number>\<project>\<build definition>\TestResults\<excuting user>_<machine name> <timestamp>
    TestLocation : c:\builds\<agent number>\<project>\<build definition>\bin
    TestLogsDir : C:\Builds\<agent number>\<project>\<build definition>\TestResults\<excuting user>_<machine name> <timestamp>\In\<machine name>
    TestOutputDirectory : C:\Builds\<agent number>\<project>\<build definition>\TestResults\<excuting user>_<machine name> <timestamp>\In\<GUID>\<machine name>
    TestResultsDirectory : C:\Builds\<agent number>\<project>\<build definition>\TestResults\<excuting user>_<machine name> <timestamp>\In\<GUID>\<machine name>
    TestRunDirectory : C:\Builds\<agent number>\<project>\<build definition>\TestResults\<excuting user>_<machine name> <timestamp>
    TestRunResultsDirectory : C:\Builds\<agent number>\<project>\<build definition>\TestResults\<excuting user>_<machine name> <timestamp>\In\<machine name>

    Tuesday, September 2, 2014 11:27 PM

All replies

  • Hi Joris,

    Thank you for sharing this knowledge and that useful blog here. They are very helpful for other community members.

    I voted your post.

    Have a nice day:)


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, September 3, 2014 5:40 AM