Amit
Amit

Reputation: 72

dotnet test command not finding any test to execute in nUnit

I am using 3.12.0 version of nunit and 3.15.1 version of nunit test adapter. I have created a project in .net and added a simple code in class to run tests. From Test->Windows->Test Explorer, I am able to view and run test cases but when I try to run from command line, It is not running anything and not giving any error also.

I am not sure what I am missing. Can anyone suggest what could be the possible reason for this?

screenshot

enter image description here

My code looks like this

using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SpecFlow.API.Test
{
    public class Class1
    {
        [SetUp]
        public void setupclass()
        {
           // Console.ReadLine();
        }

        [Test]
        public void setuptest()
        {
            Assert.Fail("ERROR");
            Console.ReadLine();
        }

        [TearDown]
        public void tearDown()
        {
            Assert.Fail("ERROR");
        }
    }
}
```

Upvotes: 0

Views: 1529

Answers (1)

Nguyễn Văn Phong
Nguyễn Văn Phong

Reputation: 14218

It seems that you are missing the TestFixture attribute

using System;
using NUnit.Framework;

namespace NUnit.Tests
{
    // Add TestFixture attribute
    [TestFixture]
    public class SuccessTests
    {
        // ...
    }
}

Upvotes: 2

Related Questions