NUnit [Test] is not a valid attribute

I included the required assemblies in a Windows class project in VS2008. When I start trying to write a test, I get a red squiggle line, and the [Test] message is not a valid attribute. I have used NUnit before ... perhaps an earlier version. What am I doing wrong? I am 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()
        {
        }
    }
}
+3
source share
3 answers

These are extra lines usingthat bother you. Use onlyusing NUnit.Framework;

Internally, NUnit.Core also has a type named Test, and you come across this.

You can use [TestAttribute]to fully describe the part of the attribute that resolves the collision.

+4

2.5.3. , DLL "lib" nunit, "framework". , dll "framework\nunit.framework.dll", . ,

+6

You are missing the [TestFixture] attribute on top of your class, and you only need to include the following entries 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()
        {
        }
    }
}
0
source

Source: https://habr.com/ru/post/1737334/


All Articles