Jos*_*man 9 visual-studio vstest vstest.console.exe
如何通过.testsettings
文件运行单元测试vstest.console.exe
?我创建了空的visual studio解决方案,创建了空单元测试项目,添加了Local.testsettings
文件作为解决方案项.
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
}
}
Run Code Online (Sandbox Code Playgroud)
<?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>
Run Code Online (Sandbox Code Playgroud)
使用以下命令运行测试时,一切正常:
>> "[path to vstest]/vstest.console.exe" [path to project]\UnitTestProject1.dll
Run Code Online (Sandbox Code Playgroud)
以下命令给出错误.
"[path to vstest]/vstest.console.exe" [path to project]\UnitTestProject1.dll /Settings:[path to settings file]\Local.testsettings
Run Code Online (Sandbox Code Playgroud)
警告:MSTest V2适配器不支持testsettings文件或ForcedLegacyMode设置为true的runsettings.[path]\UnitTestProject1.dll中没有可用的测试.确保已注册测试发现者和执行者,并且平台和框架版本设置是适当的,然后重试.
此外,可以使用/ TestAdapterPath命令指定测试适配器的路径.示例/ TestAdapterPath:
所以我添加了/TestAdapterPath:[project path/bin/Debug]
参数.在Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
与发现者和执行人这里位于.但是我没有关于指定测试适配器的最后一句话得到了相同的错误.
我想知道是否有人可以解决这个问题.
Jos*_*man 11
解决方案是使用Visual Studio默认情况下Microsoft.VisualStudio.QualityTools.UnitTestFramework
将Microsoft.VisualStudio.TestPlatform.TestFramework
其添加到单元测试项目中.所以你可以通过删除两个包NuGet
.您应该删除MSTest.TestAdapter
和MSTest.TestFramework
安装Microsoft.VisualStudio.QualityTools.UnitTestFramework.Updated
.在这些步骤之后将发现您的单元测试.
您还可以阅读以下有关测试框架MSTest V2的有用文章.
归档时间: |
|
查看次数: |
10220 次 |
最近记录: |