How to Fix this C# issue No test matches the given testcase filter `FullyQualifiedName =

39,409

Solution 1

You don't use a Main method to run a test.

Instead, put a [TestMethod] annotation on the methods you want to run as tests. The test runner will take care of creating an instance of your test class and calling these methods.

Methods with the [TestMethod] annotation must be public and void, must not be static and should take no arguments. Even if you put [TestMethod] on your Main method, the test would likely not run.

Here's what your UnitTest1 class should look like:

namespace SignUpPageAssignment
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            Automation automation = new Automation();

            automation.TestMethod1();

        } 
    }

}

Solution 2

Have resolved issue with "No test matches the given testcase filter FullyQualifiedName" by running updates to latest version for next packages:

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

For NUnit test project:

NUnit3TestAdapter

Solution 3

My case is - an old project with NUnit 2.5 opened in a new VS2019 gives the same error.

As NUnit 2.x does not included into VS2019 by default - you need to install it.

Go to Menu -> Extensions -> ManageExtensions

then search for "NUnit 2 Test Adapter"

then install it.

That helped me.

Solution 4

I was able to resolve the same error message by changing the Default Processor Architecture in Visual Studio 2017. I had to go to Test -> Test Settings -> Default Processor Architecture -> x64. It seems that I had a mismatch between this setting and the Platform target for my test projects.

Solution 5

I had the same error. For me, the cause was missing packages:

NUnit.Engine
NUnit3TestAdapter
Share:
39,409

Related videos on Youtube

touqeer
Author by

touqeer

Updated on April 05, 2022

Comments

  • touqeer
    touqeer about 2 years

    I am new to C# and Selenium and I have pretty much made a number of scripts but there comes a problem when I make more than 1 method or more than 1 class single method and single class always runs good.

    I have tried every possible solution on the internet and my self tried solution in which I made a new project and copied the main code other than class name, method name and namespace and pasted it onto new project it worked fine this is the same issue but I want to know what the problem really is.

    These are the Four Classes:
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace SignUpPageAssignment
    {
    
        public class SignUpDetails
        {
            public static string registerPageReDirect = "login_register";
            public static string signUpUserNameID = "username";
            public static string signUpPasswordID = "password";
            public static string confirmPasswordID = "re_password";
            public static string fullNameID = "full_name";
            public static string signUpEmailID = "email_add";
            public static string signUpUserName = "TouqeerABCDEFGHI";
            public static string signUpPassword = "Password@123";
            public static string confirmPassword = "Password@123";
            public static string fullName = "Touqeer Saleem";
            public static string email = "[email protected]";
            public static string checkBox = "tnc_box";
            public static string captchaForm = "captcha-form";
            public static string signUpButton = "Submit";
    
        }
    }
    
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace SignUpPageAssignment
    {
    public class LoginDetails
       {
           public static string loginUserNameID = "username";
           public static string loginPasswordID = "password";
           public static string loginUserName =   SignUpDetails.signUpUserName;
           public static string loginPassword = SignUpDetails.signUpPassword;
           public static string loginButton = "login";
           public static string redirectToLogin = "Click here to login";
    
       }
    }
    
    
    
    using OpenQA.Selenium;
    using OpenQA.Selenium.Chrome;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;
    
    namespace SignUpPageAssignment
    {
    class Automation
    {
            public void TestMethod1()
            {
                IWebDriver driver = new ChromeDriver();
    
    
                driver.Url = "http://adactin.com/HotelApp/";
    
                // SIGN UP START
                                   driver.FindElement(By.ClassName(SignUpDetails.registerPageReDirect)).Click();
    
    
                driver.FindElement(By.Id(SignUpDetails.signUpUserNameID)).SendKeys(SignUpDetails.signUpUserName);
                driver.FindElement(By.Id(SignUpDetails.signUpPasswordID)).SendKeys(SignUpDetails.signUpPassword);
                driver.FindElement(By.Id(SignUpDetails.confirmPasswordID)).SendKeys(SignUpDetails.confirmPassword);
                driver.FindElement(By.Id(SignUpDetails.fullNameID)).SendKeys(SignUpDetails.fullName);
                driver.FindElement(By.Id(SignUpDetails.signUpEmailID)).SendKeys(SignUpDetails.email);
                driver.FindElement(By.Id(SignUpDetails.checkBox)).Click();
                driver.FindElement(By.Id(SignUpDetails.captchaForm)).SendKeys("");
    
                Thread.Sleep(5000);
    
                driver.FindElement(By.Id(SignUpDetails.signUpButton)).Click();
    
                //SIGN UP END
    
                //LOGIN IN START
    
                driver.FindElement(By.LinkText(LoginDetails.redirectToLogin)).Click();
                driver.FindElement(By.Id(LoginDetails.loginUserNameID)).SendKeys(LoginDetails.loginUserName);
                driver.FindElement(By.Id(LoginDetails.loginPasswordID)).SendKeys(LoginDetails.loginPassword);
                driver.FindElement(By.Id(LoginDetails.loginButton)).Click();
    
                //LOGIN IN STOP
    
                //IWebElement result =     driver.FindElement(By.ClassName("reg_success"));
    
    
                //Assert.Equals("reg_success", result);
    
            }
        }
    }
    
    
    using System;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    
    namespace SignUpPageAssignment
    {
    [TestClass]
    public class UnitTest1
    {
        public static void Main(String[] args)
        {
            Automation automation = new Automation();
    
            automation.TestMethod1();
    
        } 
    }
    }
    

    I am making a signup automation script that signups and after signup it logins

    The error that is displayed is :

    [12/28/2018 10:44:11 PM Informational] Executing test method 'SignUpPageAssignment.UnitTest1.Main'
    [12/28/2018 10:44:11 PM Informational] Executing test method 'SignUpPageAssignment.UnitTest1.Main'
    [12/28/2018 10:44:11 PM Informational] ------ Run test started ------
    [12/28/2018 10:44:14 PM Warning] No test matches the given testcase filter `FullyQualifiedName=SignUpPageAssignment.UnitTest1.Main` in C:\Users\touqeer\source\repos\SignUpPageAssignment\SignUpPageAssignment\bin\Debug\SignUpPageAssignment.dll
    [12/28/2018 10:44:14 PM Informational] ========== Run test finished: 0 run (0:00:03.6212841) ==========
    
    • Olivier Jacot-Descombes
      Olivier Jacot-Descombes over 5 years
      Seems to be an issue with the unit tests, not with your code. See: github.com/nunit/nunit/issues/2962
    • Luke Woodward
      Luke Woodward over 5 years
      @OlivierJacot-Descombes: (1) the error is with the posted code: the asker has put a Main method where a test method is required, (2) your link refers to NUnit whereas the asker is using MSTest.
    • Olivier Jacot-Descombes
      Olivier Jacot-Descombes over 5 years
      Well observed Luke!
  • user1735921
    user1735921 almost 5 years
    how to write in xUnit?
  • Allan.C
    Allan.C about 4 years
    Wow! This fixed my problem, thanks for your response.
  • SndrSchnklshk
    SndrSchnklshk almost 4 years
    This is it! Only add Microsoft.NET.Test.Sdk, MSTest.TestAdapter. The last one you will get for free :)
  • Joan.bdm
    Joan.bdm almost 3 years
    @user1735921 chec prkumk answer: install "xunit.runner.visualstudio" nuget package
  • leodali
    leodali about 2 years
    Simple as it gets, but worked :)
  • kiddagger
    kiddagger about 2 years
    Missing NUnit3TestAdapter was my issue. Thank you!