微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何解决此C#问题没有测试与给定的测试用例过滤器匹配`FullyQualifiedName =

我是C#和Selenium的新手,我制作了许多脚本,但是当我使用多个方法一个以上类的单个方法并且单个类始终运行良好时,就会出现问题.

我已经尝试了Internet上所有可能的解决方案,并且尝试了一个新项目,并复制了除类名,方法名和名称空间以外的主要代码,并将其粘贴到新项目中,这是我自己尝试过的解决方案,但仍然可行我想知道真正的问题是什么.

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 = "sabaloch67@gmail.com";
        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();

    } 
}
}

我正在制作一个注册自动化脚本,注册后会登录

显示错误是:

[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) ==========

解决方法:

您不使用Main方法来运行测试.

而是在要作为测试运行的方法上放置[TestMethod]批注.测试运行器将负责创建测试类的实例并调用这些方法.

带有[TestMethod]批注的方法必须是public和void,不能是静态的,并且不能使用任何参数.即使将[TestMethod]放在Main方法上,测试也可能不会运行.

这是UnitTest1类的外观:

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

            automation.TestMethod1();

        } 
    }

}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐