【问题标题】:MSTest with WatiN using DeploymentItem - files not getting copiedMSTest 与 WatiN 使用 DeploymentItem - 文件未被复制
【发布时间】:2011-12-03 00:23:57
【问题描述】:

我一直在浏览 stackoverflow,阅读有关 MSTest 和 DeploymentItem 的其他问题;我已经听从了所有的建议,但没有什么对我有用。我的测试项目中有一个名为“ImportFiles”的文件夹,其中有一个名为“contacts.xlsx”的文件,其属性“复制到输出目录”设置为“始终复制”,但运行测试时该文件没有被复制。

下面的示例代码。有任何想法吗?

[TestMethod]
[DeploymentItem(@"ImportFiles/contacts.xlsx")]
public void MyTestName()
{
    // get the file and use it here
    var extensions = new {"xlsx"};
    var d = new DirectoryInfo(this.TestContext.TestDeploymentDir);
    List<FileInfo> importFiles = d.GetFiles().Where(f => extensions.Any(e => f.Extension.EndsWith(e))).ToList();
}

在测试初始化​​时,我也一直在监视目录。除了 dll 配置和 pdb 文件外,什么都没有被复制。

【问题讨论】:

    标签: c# testing mstest deploymentitem


    【解决方案1】:

    我发现是这样的:

    我使用 Resharper,并且经常使用 Resharper 控件运行测试。 Resharper v6 没有使用 DeploymentItems 正确初始化 MSTest,即,DeploymentItems 永远不会复制到输出目录。解决方案是不使用 Resharper 命令来运行测试。如果您使用 VS 2010 的“测试”或“调试”命令(或使用“测试”菜单中的 Ctrl R、T),则一切都已正确部署并且测试将运行。

    【讨论】:

    • ReSharper 7.1.3 似乎也有这种行为。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多