我有一個mut.cs如下。單聲道NUnit測試
using System; namespace ns { public class Arith { public int Add(int x, int y) { return x + y; } public int Mul(int x, int y) { return x * y; } } }
我想出了這個單元測試 - mut_test.cs
using NUnit.Framework; using System; using ns; namespace Unit.Tests { [TestFixture] public class ArithTests { private Arith m_arith = null; [Setup] public void Setup() { m_arith = new Arith(); } [Test] public void ValidateAdd() { int res = m_arith.Add(10,10); Assert.AreEqual(20, res); } [TearDown] public void TearDown() { m_arith = null; } } }
我跑以下命令。
gmcs -debug -t:library -r:System -r:$NUNITLIB -out:mut.dll mut_test.cs mut.cs
但我得到以下錯誤。 $ NUNITLIB的別名是$ NUNITLIB = $ NUNITBIN /框架/ nunit.framework.dll中
mut_test.cs(9,10): error CS0118: `Unit.Tests.ArithTests.Setup()' is a `method' but a `type' was expected mut_test.cs(9,10): error CS0246: The type or namespace name `SetupAttribute' could not be found. Are you missing a using directive or an assembly reference?
可能是什麼問題?
是的,這是問題的原因。謝謝! – prosseek 2010-06-03 16:19:38