2014-12-02 67 views
2

我有一套单元测试,需要我的办公室以外的人员无法访问Visual Studio。我有一个包含Nunit测试的项目,我想部署一个Windows窗体应用程序,在其中单击按钮,带有单元测试的项目将执行NUnit GUI Runner。我可以使用Visual Studio中的NUnit GUI运行单元测试,但是可以使用已部署的WinForms应用程序中的NUnit GUI运行NUnit测试吗?如何从已部署的Windows Forms应用程序运行NUnit

我不想在WinForms应用程序中使用NUnit,只需启动NUnit-Gui并运行测试即可。基本上WinForms应用程序上的一个按钮将启动NUnit-Gui。

+0

你是问关于从WinForms应用程序运行[NUnit的桂(http://www.nunit.org/index.php?p=nunit-gui&r=2.2.10)?或者NUnit-Gui作为一个独立的测试运动员做你想做的事情? – 2014-12-02 15:36:04

+0

@hunch_hunch我想从WinForms应用程序启动NUnit-Gui来运行WinForms应用程序内的单独项目的单元测试。 – 2014-12-02 15:40:13

回答

1

这是一个简单的例子,当单击一个按钮时,如何从C#WinForms应用程序启动NUnit-Gui(针对包含NUnit测试的特定程序集)。这假定用户运行应用程序的机器已经在特定路径中安装了NUnit。您当然可以将NUnit与您的WinForms应用程序一起部署和/或配置它运行的位置。使用此代码,用户仍然必须在弹出的NUnit窗口中单击Run按钮才能实际运行测试。

namespace NUnitGuiRunner 
{ 
    using System; 
    using System.Windows.Forms; 

    using System.Diagnostics; 

    public partial class Form1 : Form 
    { 
     public Form1() 
     { 
      InitializeComponent(); 
     } 

     private void RunTestsButton_Click(object sender, EventArgs e) 
     { 
      Process.Start(@"C:\NUnit 2.6.2\bin\nunit.exe", @"C:\PathToTests\SomeUnitTests.dll"); 
     } 
    } 
} 
相关问题