我最近从 Visual Build Pro 8 切换到 Visual Build Pro 9,并且在构建某些测试项目时遇到了问题。这似乎与必须使用 PrivateObject 类来测试私有方法的各种单元测试有关,这是我无法更改的。
有问题的项目引发以下(示例)错误:
RetrieveXmlControllerTest.cs(22,9): error CS0246: The type or namespace name 'RetrieveXmlController_Accessor' could not be found (are you missing a using directive or an assembly reference?) [C:\..\CorrectSubsystemTests.csproj]
它指的是以下代码:
_targetAccessor = new RetrieveXmlController_Accessor(new PrivateObject(_target));
我尝试将 Microsoft UnitTesting dll 添加为 DeploymentItem(像这样),但这也无济于事。
[TestInitialize]
[DeploymentItem("Microsoft.VisualStudio.TestTools.UnitTesting.dll")]
public void Initialise() { // Blah Blah Blah // }
如果我通过 Visual Build Pro 8 运行该项目,它仍然可以正确构建,但我不明白如何。有没有人有任何想法?