Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing 用Gallio运行NUnit测试_Unit Testing_Model View Controller_Nunit_Gallio - Fatal编程技术网

Unit testing 用Gallio运行NUnit测试

Unit testing 用Gallio运行NUnit测试,unit-testing,model-view-controller,nunit,gallio,Unit Testing,Model View Controller,Nunit,Gallio,我正在为一个项目写一些NUnit测试。我向解决方案中添加了一个新类库。这是正确的项目类型吗 我添加了一个参考: using NunitFramework; 并添加了我的测试 我安装了Gallio,但我不确定它是否配置正确。我对使用这个很陌生,我希望有人能告诉我你是如何运行测试的 据我所知,您可以右键单击并选择“运行所有测试”。或者,我认为您可以单击[Test]属性,然后单击run或debug 或者,如何将测试加载到“测试结果”窗口以运行调试它们?基本上是正确的。您的单元测试应该如下所示: us

我正在为一个项目写一些NUnit测试。我向解决方案中添加了一个新类库。这是正确的项目类型吗

我添加了一个参考:

using NunitFramework;
并添加了我的测试

我安装了Gallio,但我不确定它是否配置正确。我对使用这个很陌生,我希望有人能告诉我你是如何运行测试的

据我所知,您可以右键单击并选择“运行所有测试”。或者,我认为您可以单击
[Test]
属性,然后单击run或debug


或者,如何将测试加载到“测试结果”窗口以运行调试它们?

基本上是正确的。您的单元测试应该如下所示:

using System;
using NUnit.Framework;

namespace Demo
{
  [TestFixture]
  public class SampleTestFixture
  {
      [Test]
      public void SampleTest()
      {
         // my test here...
      }
  }
}
在调试模式下编译测试项目(类库可以)。现在,您可以在任何支持NUnit的运行程序中运行测试套件:

  • 任何测试运行程序(、等)都有一个很好的教程,解释如何使用Gallio测试运行程序。示例使用而不是NUnit,但都是一样的
  • 内置的NUnit或runner
  • 内置VS测试运行程序(由Gallio接口),如果您的Visual Studio版本包含MS测试工具。您应该能够在测试工具窗口中看到您的测试,但是如果您最初没有将项目创建为测试项目,则有一种方法可以让VS将其识别为测试项目
  • 您还可以使用作为VS.IMHO外接程序的轻量级快速测试运行程序,它无疑是直接从VS IDE运行单元测试的最简单、最有效的方法