Using NUnit with Visual Studio 2005 Express Editions

  • 允许通过Build Toolbar选择"Debug" or "Relese"设置

"工具" -> "选项..." -> 选择"显示所有设置" -> "项目和解决方案" ->选择"显示高级生成配置"

  • 在VS2k5 Express工程中使用NUnit-GUI测试(以Visual C# 2005 Express为例)
    1. 创建一个新的类库工程。

      NUnit.1

    2. 添加NUnit框架引用。

      NUnit.2

    3. 编写测试代码。
      using System;
              using NUnit.Framework;
              namespace NUnitTest
              {
              [TestFixture]
              public class Class1
                  {
              [Test]
              public void Test1()
              {
              int a = 1;
              int b = 2;
              int sum = a + b;
              Assert.AreEqual(sum, 3);
              }
              }
              }
    4. 使用NUnit-GUI测试。这一步需要修改.csproj文件,加入下面代码:
      <PropertyGroup>
        <Nunit_Path Condition="'$(NUNIT_PATH)' == ''">C:\Program Files\NUnit 2.4.2</Nunit_Path>
        <StartAction>Program</StartAction>
        <StartProgram>$(NUNIT_PATH)\bin\nunit.exe</StartProgram>
        <StartArguments>/run $(TargetFileName)</StartArguments>
        <!--.csproj.user overwrites those values!-->
      </PropertyGroup>
      重新加载工程,F5

      NUnit.3

posted on 2007-08-10 10:54  Voidclass  阅读(711)  评论(0编辑  收藏  举报

导航