BrahimHZ95
BrahimHZ95

Reputation: 41

Can't run a simple Unit Test #Cs #VS19 #MSTest

I'm new in unit test and I'm trying to run a simple test but after push the "run test" button it's load then nothing

What's wrong ????!!

using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestNinja.Fundamentals;

namespace TestNinga.UnitTests
{
    [TestClass]
    public class ReservationTests
    {
        [TestMethod]
        public void CanBeCancelledBy_UserIsAdmin_ReturnTrue()
        {

            var reservation = new Reservation();

            var result = reservation.CanBeCancelledBy(new User { IsAdmin = true });

            Assert.IsTrue(result); 
            
        }
    }
}

enter image description here

enter image description here

Upvotes: 1

Views: 1806

Answers (2)

BrahimHZ95
BrahimHZ95

Reputation: 41

I find the isssue , I just update/add this package in my test solution :

  • Microsoft.NET.Test.Sdk
  • MSTest.TestAdapter
  • MSTest.TestFramework

Upvotes: 2

Misha Zaslavsky
Misha Zaslavsky

Reputation: 9682

It looks like nothing is wrong. Sometimes this happens also to me and sometimes I fix it by closing the VS, deleting the bin & obj folders, opening the VS, and cleaning the solution. One time I also noted out that the process runs in the background and stuck and as a result, the tests didn't run, so I killed the process, and then it started working.

If it won't help you always can see what is the error you get and share more information.

To see the error you should open the Output pane and in the Show output from: box, you should choose the tests option.

Upvotes: 2

Related Questions