如何使用.testsettings
文件运行单元测试vstest.console.exe
?我创建了空的 Visual Studio 解决方案,创建了空的单元测试项目,将Local.testsettings
文件添加为解决方案项。
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
}
}
<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="Local" id="1109524d-9809-4423-b7fa-fad429ebfd8d" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Description>These are default test settings for a local test run.</Description>
<Deployment enabled="false" />
<Execution hostProcessPlatform="MSIL">
<TestTypeSpecific>
<UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
<AssemblyResolution>
<TestDirectory useLoadContext="true" />
</AssemblyResolution>
</UnitTestRunConfig>
</TestTypeSpecific>
<AgentRule name="LocalMachineDefaultRole">
</AgentRule>
</Execution>
<Properties />
</TestSettings>
当我使用以下命令运行测试时,一切正常:
>> "[path to vstest]/vstest.console.exe" [path to project]\UnitTestProject1.dll
下面的命令给出了一个错误。
"[path to vstest]/vstest.console.exe" [path to project]\UnitTestProject1.dll /Settings:[path to settings file]\Local.testsettings
警告:MSTest V2 适配器不支持将 ForcedLegacyMode 设置为 true 的 testsettings 文件或 runsettings。[路径]\UnitTestProject1.dll 中没有可用的测试。确保测试发现者和执行者已注册并且平台和框架版本设置正确,然后重试。
此外,可以使用 /TestAdapterPath 命令指定测试适配器的路径。示例 /TestAdapterPath:。
所以我添加了/TestAdapterPath:[project path/bin/Debug]
参数。with 发现者和执行Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
者位于此处。但是没有关于指定测试适配器的最后一句话,我得到了同样的错误。
我想知道是否有人可以解决这个问题。