标题: 有关NUnit中用例次序的问题 [打印本页] 作者: dqf 时间: 2009-11-12 16:12 标题: 有关NUnit中用例次序的问题 测试用例中的代码:
using System;
using NUnit.Framework;
using NUnitTest;
namespace NUnitTestTest
{
[TestFixture]
public class CalculatorTest
{
private Calculator cal;
private int a, b, expected, actual;
[TestFixtureSetUp]
public void InitClass()
{
cal = new Calculator();
a = 10;
b = 2;
}
[TestFixtureTearDown]
public void FinalizeClass()
{
Console.WriteLine("执行TestFixtureTearDown");
}
[Test]
public void TestAdd()
{
Console.WriteLine("TestAdd() Begin");
expected = 12;
actual = cal.Add(a, b);
Assert.AreEqual(expected, actual);
Console.WriteLine("TestAdd() End");
}
[Test]
public void TestMinus()
{
Console.WriteLine("TestMinus Begin");
expected = 8;
actual = cal.Minus(a,b);
Assert.AreEqual(expected, actual);
Console.WriteLine("TestMinus End");
}
[Test]
public void TestMultiply()
{
Console.WriteLine("TestMultiply() Begin");
expected = 20;
actual = cal.Multiply(a, b);
Assert.AreEqual(expected, actual);
Console.WriteLine("TestMultiply() End");
}
[Test]
public void TestDivide()
{
Console.WriteLine("TestDivide() Begin");
expected = 5;
actual = cal.Divide(a, b);
Assert.AreEqual(expected, actual);
Console.WriteLine("TestDivide() End");
}