Some of our MSTest unit tests search files contained within the project. To this end, the unit test walks up the directory tree starting with the current directory, looking for well known files within each directory being inspected. The tests run fine in the IDE and in CruiseControl, but not in TeamCity. TeamCity copies the test assemblies to an entirely unrelated directory, outside of the solution directory, causing the project directory lookup process to fail.
I realize that directory traversal from supposedly self contained assemblies may suggest a "procedure smell", but we did investigate alternatives.
Among the other alternatives, MSTest could get to the files if the build deploys the web application to IIS (possibly through an installer project); MSTest can then access these files directly from the web applications using a URI. Needless to say, this adds moving parts to the integration build, it increases the build overhead and brings about the problem of avoiding URI clashes for the collection of build configurations (in case some builds are triggered at the same time).
Other alternatives include various schemes for pulling the necessary files into the test environment. As long as these require intervention from the developer writing the unit test, we prefer to avoid them if possible.
To my questions.
1. Is it possible to force MSTest to run within the solution directory or a subdirectory thereof?
2. Does TeamCity provide MSTest with runtime information that includes the path to the working copy of the solution or project being tested?
3. Any other comments that you may find pertinent.