Reputation: 71101
I've included the necessary assemblies into a Windows Class project in VS2008. When I start to try to write a test I get a red squiggle line and the message [Test] is not a valid attribute. I've used NUnit before... maybe an earlier version. What am I doing wrong? I'm on version 2.5.2.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit;
using NUnit.Core;
using NUnit.Framework;
namespace MyNamespace
{
public class LoginTests
{
[Test]
public void CanLogin()
{
}
}
}
Upvotes: 4
Views: 3166
Reputation: 46173
It is the extra using
lines getting you in trouble. Only use using NUnit.Framework;
Internally NUnit.Core also has a type named Test
and you are colliding with that.
Altenatively you could use [TestAttribute]
fully spelling out the Attribute part resolves the collision.
Upvotes: 5
Reputation: 71
I had a similar problem to this using version 2.5.3. The problem was that I was looking for the dll files in the "lib" directory of my nunit installation when I should have been looking in the "framework" directory. So when I referenced the "framework\nunit.framework.dll" dll everything worked. Hope this helps
Upvotes: 7
Reputation: 1601
You are missing the [TestFixture] attribute on top of your class, also, you only need to include the following usings for NUnit: using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
namespace MyNamespace
{
[TestFixture]
public class LoginTests
{
[Test]
public void CanLogin()
{
}
}
}
Upvotes: 0