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.anti-gravitydesign.com