c# - 使用 NUnit 测试 Windows 窗体逻辑

标签 c# winforms unit-testing nunit

我正在研究单元测试,我想知道是否可以使用 NUnit 测试对话框或表单的某些特殊功能。 .我试过NUnitForms ,但它缺乏良好的文档,而且似乎没有人维护该项目。是真的吗?

如果您有任何测试 Windows 窗体的经验,请指出正确的方法。任何意见或信息表示赞赏。谢谢!

最佳答案

我在使用 NUnitForms 时遇到了同样的问题。我可以启动一个表单并单击一个按钮,但我不知道如何让对话框工作,而且我根本找不到太多相关信息。 我认为这个博客是最有用的: http://blogs.msdn.com/john_daddamio/archive/2006/11/06/getting-started-with-nunitforms.aspx

我不得不在我的 app.config 中重新映射 NUnitForms 程序集,以使其与最新版本一起使用,如下所示:

<configuration>
   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
      <dependentAssembly>
        <assemblyIdentity name="nunit.framework"
          publicKeyToken="96d09a1eb7f44a77"
          culture="neutral" />
        <bindingRedirect oldVersion="2.2.7.0" newVersion="2.5.2.9222" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

( http://duncanjasmith.blogspot.com/2007/08/using-nunitforms-with-nunit-framework.html )

我希望这个帖子能帮到我,但我可能仍会尝试白色项目 (http://www.codeplex.com/white)。

关于c# - 使用 NUnit 测试 Windows 窗体逻辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2198454/

相关文章:

c# - Caliburn Micro WPF : Message. Attach with guard 属性禁用整个主机控制

c# - 在 ASP.NET C# 中解析 json 文件

c# - 如何获取从特定类型继承的类的所有方法

unit-testing - 单元测试后 Controller .NET Web Api

unit-testing - 测试Gradle脚本指南

c# - 与 Contract.Requires<T> 相比抛出异常?

winforms - 无法从应用程序打开有关网络共享的 CHM 帮助

c# - 附加信息 : Unable to cast object of type 'System.Windows.Forms.BindingSource' to type 'System.Data.DataTable'

c# - 在 C# 中使用 ControlArrays 减少代码冗余的想法

c# - 使用 Moq 模拟 'new()' 约束