1

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

BrahimHZ95
  • 31
  • 4
  • 1
    Check the output window, if there are any more details. – Marco Jul 25 '21 at 18:32
  • Hope the following reference could be helpful: [Tests not running in Test Explorer](https://stackoverflow.com/questions/23363073/tests-not-running-in-test-explorer) – Xingyu Zhao Jul 26 '21 at 02:31

2 Answers2

2

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.

Misha Zaslavsky
  • 8,414
  • 11
  • 70
  • 116
  • after delete bin & obj and open the output window this the result of running a test : ---------- Starting test run ---------- No test matches the given testcase filter `FullyQualifiedName=TestNinga.UnitTests.ReservationTests.CanBeCancelledBy_UserIsAdmin_ReturnTrue` in C:\Users\try\Desktop\TestNinja\TestNinga.UnitTests\bin\Debug\TestNinga.UnitTests.dll ========== Test run finished: 0 Tests run in 910.4 ms (0 Passed, 0 Failed, 0 Skipped) ========== – BrahimHZ95 Jul 27 '21 at 17:30
  • Good call. When I went to the `Output` pane and selected `Show output from: Tests`, I was able to see a Cleanup function throwing a null reference error :0 – Matthew McCord Nov 30 '21 at 17:09
1

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

  • Microsoft.NET.Test.Sdk
  • MSTest.TestAdapter
  • MSTest.TestFramework
BrahimHZ95
  • 31
  • 4
  • Consider [accepting the answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work). – Xingyu Zhao Aug 05 '21 at 06:39