NUnit单元测试整理之基本语法

发表于:2009-12-25来源:作者:点击数: 标签:
NUnit单元测试整理之基本语法 单元测试方法 1.TestFixtureSetUp与TestFixtureTearDown的用法 TestFixtureSetUp:在所有当前选中的标记为Test的方法运行之前运行 TestFixtureTearDown:在所有当前选中的标记为Test的方法运行后运行 Code using System; using Sy

  NUnit单元测试整理之基本语法   单元测试方法  

      1.TestFixtureSetUp与TestFixtureTearDown的用法

  TestFixtureSetUp:在所有当前选中的标记为Test的方法运行之前运行

  TestFixtureTearDown:在所有当前选中的标记为Test的方法运行后运行

Code

  using System;

  using System.Text;

  using NUnit.Framework;

  namespace NUnitTest

  {

  [TestFixture]

  public class CaculatorTest

  {

  private Caculator cac;

  private int a;

  private int b;

  ///

  /// 声明为TestFixtureSetUp的方法将在所有选中的TestCase调用之前调用,通常用来初始化数据库连接

  ///

  [TestFixtureSetUp]

  public void InitUtility()

  {

  Console.Write("Caculator Invoked!");

  }

  ///

  /// 声明为TestFixtureTearDown的方法将在所有选中的TestCase调用之后调用,通常用来销毁数据库连接

原文转自:http://www.ltesting.net