简体   繁体   中英

How to set relative path for DeploymentItem in MSTest?

A lot of people struggle with relative path in DeploymentItem . The relative path is from Solution Folder. This can only apply when run from Visual Studio, because mstest.exe is launched with compiled project (and not sln file) as dll and thus it cannot correctly determined the relative path of deployment item.

I have found that I should set the DeploymentItem relative path in testrun.config by RelativePathRoot element. But there is almost no documentation for RelativePathRoot which is strange. How do you set relative path to MSTest ?

The correct approach is to set the Working directory as solution directory when calling MSTest.exe. This is easy way how to resolve DeploymentItem problems.

In consequences it means that if you have multiple projects and multiple solutions (every solution contains some of those projects) in you repository, that all these solution (sln files) MUST be in the same directory. Because the relative path from every any solution to one project must be same. So I strongly recommend to have one root directory named Solutions and all these sln files inside.

If the test project is contained in two different solutions in different directories, there will be different relative path to DeploymentItem and you will never configure MSTest with deploymentPath properly in both solutions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM