[2155] TestContext object properties are null with deployment disabled.

I have encountered an issue that is causing me some headache.  I am using the Testcontext property within my MSTest unit tests to retrieve directory information about the current running directory of the tests being executed.  I use this path to construct a relative path to access some solution level data files that are used as test data resources (DataSource attribute on test methods).

When I configure my active testconfig to disable deployment, all of the properties in the TestContext object related to paths (such as TestDeploymentDir, TestDir,TestRunDirectory, etc are all null.

I would think at least TestDir or TestRunDirectory should have some path in them.

Simple steps to reproduce.

*create a new unit test project.
*add new unit test class
*make sure your active testconfig has deployment turned off.
*Resharper test options are default settings (shadow copy on, project output etc.)
* uncomment the MyClassInitialize method
* add the following code:

      Debug.WriteLine("Deployment Directory: {0}", new object[] {testContext.DeploymentDirectory});
      Debug.WriteLine("Test Deployment Directory: {0}",new object[]{testContext.TestDeploymentDir});
      Debug.WriteLine("Test Directory: {0}",new object[] {testContext.TestDir});
      Debug.WriteLine("Test Run Direcotry: {0}",new object[]{testContext.TestRunDirectory});
      Debug.WriteLine("Test Results Directory: {0}",new object[]{testContext.TestResultsDirectory});
      Debug.WriteLine("Results Directory: {0}",new object[]{testContext.ResultsDirectory});
*Create a simple unit test (any will do as you are just using it to get the MyClassInitialize method to execute.
*Debug this unit test using the resharper test runner
*Note the output the directories will be blank/null

Has anyone else encountered this issue?  Any workarounds?  I can turn on deployment but then I am having trouble with the unit tests finding thier datasource connection which is an xml file |DataDirectory|incoming.xml.

Thanks for the insight in advance.

Thanks for reporing this issue, it's fixed in recent EAP build.


I wanted to run tests in a project which is not mine and found out that following directory is not set in the Context


The Test works with mstest but not with resharper This is in Resharper 6.0.

Thanks in advance


Please sign in to leave a comment.