TestContext folders explained

 

One of the FAQ around MSTEST is on the folders exposed by TestContext. What each of them means and which one to use when.

Below is a quick summary of the various folders and their usage.

 

TestRunDirectory (TestDir)

clip_image001 Indicates the high level folder created for the current test run. This would have “In” and “Out” subfolders inside it.

TestDeploymentDir

clip_image001[1] Indicates the “Out” sub folder under the “TestRunDirectory”. This is where the items needed for the current run would be deployed prior to the test run.

clip_image001[2]  If you need to refer to any of your deployed files, you should be using this variable.

TestRunResultsDirectory (TestLogsDir)

clip_image001[3] Indicates the “In” subfolder under “TestrunDirectory”. This is the folder where the run level attachments and data collector files would be stored after the test run.

clip_image001[4] If you need to create temp files during the test run, you should be using this variable.

TestResultsDirectory

clip_image001[5] Indicates a sub folder inside “In” folder corresponding to the current test case.

clip_image001[6] For each test case in the test run, a sub folder would be created which would have the test case level data collector logs like “EventLogs”.

clip_image001[7] If you add a file to the test result using TestContext.AddResult(), the file would go under the “TestResultsDirectory” corresponding to that test case.

 

Hope you found it useful. if you have further questions, please post your queries.