Parveen
Parveen

Reputation: 682

Unit Testing is not showing Test Result

I have created one Unit Test Project where I am testing my View but it is not showing any result. Below is my Code:-

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SinglePage.Controllers;
using System.Web.Mvc;

namespace UnitTestProject1
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            Console.WriteLine("METHOD");
            //Arrange
            HomeController ctrl = new HomeController();

            Console.WriteLine("Pass");
            //Act
            ViewResult r = ctrl.Index() as ViewResult;

            //Asert
            Assert.AreEqual("View1", r.ViewName);
        }

    }
}

After click on "Run All" from Test Explorer I am getting below message:

------ Discover test started ------

No plugin found which can import settings file with extension '.csproj'. Either select a new settings file or install an extension which understands this settings file extension.

========== Discover test finished: 0 found (0:00:00.0010094) ==========

Upvotes: 3

Views: 2199

Answers (2)

Niraj Motiani
Niraj Motiani

Reputation: 71

visual studio unit testing setting uses .runSettings file to pull all settings, you can set it to use auto, for me the issue was Test -> Configure Run settings -> (file ending in .runSettings) was not selected and some other file was selected so unit tests were not discoverable at all so visual studio just aborted testing, fixed that and it all went through

Upvotes: 0

Ekk
Ekk

Reputation: 5715

You can user Debug.WriteLine to print to Output tab on Visual Studio.

[TestMethod]
public void TestMethod1()
{
    Debug.WriteLine("METHOD");
    //Arrange
    HomeController ctrl = new HomeController();

    Debug.WriteLine("Pass");
    //Act
    ViewResult r = ctrl.Index() as ViewResult;

    //Asert
    Assert.AreEqual("View1", r.ViewName);
}

Upvotes: 1

Related Questions