我有一组单元测试,需要由不在我办公室的人运行,他们无法访问visual studio。我有一个包含Nunit测试的项目,我想部署一个windows应用程序,在这里单击一个按钮,带有单元测试的项目将执行NUnit GUI。我可以在Visual中使用NUnit GUI运行单元测试,但是可以使用部署的NUnit应用程序的NUnit GUI运行NUnit测试吗?
我不打算在NUnit应用程序中使用WinForms,只需启动NUnit-Gui并运行测试。基本上,WinForms应用程序上的一个按钮将启动NUnit-Gui。
发布于 2014-12-02 15:55:42
这是一个简单的示例,说明如何在单击按钮时从NUnit-Gui WinForms应用程序启动NUnit (针对包含NUnit测试的特定程序集)。这假设用户正在运行的机器上安装了NUnit,并在特定的路径上安装了应用程序。当然,您可以在NUnit应用程序中部署WinForms和/或从运行位置配置它的位置。使用此代码,用户仍然必须单击弹出的Run窗口中的NUnit按钮才能实际运行测试。
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");
}
}
}https://stackoverflow.com/questions/27253026
复制相似问题