Alperen Öz
Alperen Öz

Reputation: 25

I can't run my Nunit test in asp.net core

In my asp.net core project (vs 2017), I want to run my test method but ı click the 'run all' in test explorer, I get "Last Test Run Not Run (Total Run Time 'bla bla')" response in test explorer console. I have my Nunit NuGet package already downloaded. I think ı have some missing testing configurations for testing in asp.net core in my startup class or somewhere else or some missing NuGet packages :/ Thx in advance to everyone.

Here is my test class:

using NUnit.Framework;
using Software_Testing.Controllers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Software_Testing.Tests
{
    [TestFixture]
    public class NunitTest
    {
        GuessService GuessService = new GuessService();

        [Test]
        public void GuessTest()
        {
            var result = GuessService.Guess("This is a test description with less then 20 words.");
            Assert.AreEqual("1-3 Gün", result);
        }
    }
}

Here is my "Guess service" class which has guess method I'm using in my test method (guessTest):

    public class GuessService
    {
        public string Guess(string desc)
        {
            string s = desc;            //açıklamadaki kelime sayısına göre süre tahminlemesi yapılır...
            string[] coutn = s.ToString().Split(' ');
            int i = coutn.Count();
            if (i <= 20)
            {
                return "1-3 Gün";
            }
            else if (20 < i && i <= 40)
            {
                return "3-5 Gün";
            }
            else if (40 < i)
            {
                return "5-7 Gün";
            }
            return "";
        }
    }

And here is my ss of test explorer:

enter image description here

Upvotes: 0

Views: 379

Answers (1)

Alperen &#214;z
Alperen &#214;z

Reputation: 25

I got my solution on my own :/ I' haven't added this nugget packages below:
*NUnit3TestAdapter
*Microsoft.Net.Test.Sdk

Upvotes: 1

Related Questions