[英]MSTest V2 with x86 and x64
I have unit tests that require they run specifically as x86 and x64. 我有单元测试,要求它们专门作为x86和x64运行。 The problem I'm having is I can't ever run all unit tests because I have to switch the framework from the Test menu. 我遇到的问题是我无法运行所有单元测试,因为必须从“测试”菜单中切换框架。 Is there any better way to do this in a more automated fashion? 有没有更好的方法可以更自动化地做到这一点? Ideally there would be an Attribute I could use to specify if a test was specifically x86 or x64. 理想情况下,可以使用一个属性来指定测试是专门针对x86还是x64。 Here's an example of my code: 这是我的代码示例:
[TestMethod]
public void Testx86_Success()
{
if (!Environment.Is64BitProcess)
{
//Arrange
...
//Act
...
//Assert
Assert.IsTrue(true);
}
else
{
Assert.Inconclusive("Can't test x64 while running in x86 process.");
}
}
[TestMethod]
public void Testx64_Success()
{
if (Environment.Is64BitProcess)
{
//Arrange
...
//Act
...
//Assert
Assert.IsTrue(true);
}
else
{
Assert.Inconclusive("Can't test x86 while running in x64 process.");
}
}
You can declare conditional compilation variable and use it 您可以声明条件编译变量并使用它
#if comp_x64
[TestMethod]
public void Testx64_Success()
{
if (Environment.Is64BitProcess)
{
//Arrange
...
//Act
...
//Assert
Assert.IsTrue(true);
}
else
{
Assert.Inconclusive("Can't test x86 while running in x64 process.");
}
}
#else
. . . . your x86 test
#endif
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.