每当我尝试从Visual Studio 2012的测试资源管理器运行测试时,一些测试会被归类为“External”,即使按照“按项目分组”的方式进行分组。此时源代码也未被识别。 ![enter image description here](https://istack.dev59.com/AaLcZ.webp)
![enter image description here](https://istack.dev59.com/AaLcZ.webp)
这是因为编译时未包含pdb文件。如果你在除调试以外的解决方案配置中编译代码,必须确保包含pdb。
要实现这一点,您必须打开高级构建设置:
在新窗口中,您必须在调试信息下拉菜单中选择“pdb-only”。
这在我的情况下发生,但仅当命名空间、类名和测试方法的组合长度超过254个字符时。(MS-Test,Visual Studio 2013 12.0.40629.00 Update 5)
namespace MyTests.HaveLong.Complicated.NamespaceAsWell.AsMuchAs.EightyFive.Chars.IfThatMatters
{
[TestClass]
public class A_Long_ClassName_MayAlso_Contribute_ToThe_Issue_ThisOneIs_EightyFive_Characters_Long
{
[TestMethod]
public async Task This_IsAMsTest_TestMethod_WithAnEightyFive_CharacterName_WhichWillShow_UnderExternal()
{
}
[TestMethod]
public async Task This_IsAMsTest_TestMethod_WithAnEightyFour_CharacterName_WhichWontShowUnderExternal()
{
}
}
}
我尝试了被接受的解决方案,但没有改变任何东西,所以我还原了它,然后突然之间一切都为我修复了。VS2017。