如何修复此C#问题无测试与给定的测试用例筛选器“FullyQualifiedName”匹配=
我是C#和Selenium的新手,我已经编写了很多脚本,但是当我编写了多个方法或多个类的单个方法,并且单个类总是运行良好时,就会出现问题 我已经在互联网上尝试了所有可能的解决方案,我自己也尝试过了。在我自己尝试的解决方案中,我创建了一个新项目,复制了除类名、方法名和命名空间之外的主代码,并将其粘贴到新项目上。它工作正常。这是同一个问题,但我想知道问题到底是什么如何修复此C#问题无测试与给定的测试用例筛选器“FullyQualifiedName”匹配=,c#,selenium,selenium-webdriver,selenium-chromedriver,C#,Selenium,Selenium Webdriver,Selenium Chromedriver,我是C#和Selenium的新手,我已经编写了很多脚本,但是当我编写了多个方法或多个类的单个方法,并且单个类总是运行良好时,就会出现问题 我已经在互联网上尝试了所有可能的解决方案,我自己也尝试过了。在我自己尝试的解决方案中,我创建了一个新项目,复制了除类名、方法名和命名空间之外的主代码,并将其粘贴到新项目上。它工作正常。这是同一个问题,但我想知道问题到底是什么 These are the Four Classes: using System; using System.Collections.
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信息性]执行测试方法“SignUpPageAssignment.UnitTest1.Main”
[12/28/2018 10:44:11 PM信息]执行测试方法“SignUpPageAssignment.UnitTest1.Main”
[12/28/2018 10:44:11 PM信息]----运行测试已开始------
[12/28/2018 10:44:14 PM Warning]没有测试与C:\Users\touqeer\source\repos\SignUpPageAssignment\bin\Debug\SignUpPageAssignment.dll中给定的测试用例筛选器“FullyQualifiedName=SignUpPageAssignment.UnitTest1.Main”匹配
[12/28/2018 10:44:14 PM信息]==========运行测试完成:0运行(0:00:03.6212841)==========
您没有使用Main
方法来运行测试
相反,在要作为测试运行的方法上添加一个[TestMethod]
注释。测试运行程序将负责创建测试类的实例并调用这些方法
带有[TestMethod]
注释的方法必须是公共的
和无效的
,不能是静态的
,并且不应该接受任何参数。即使将[TestMethod]
放在Main
方法上,测试也可能不会运行
下面是您的UnitTest1
类的外观:
namespace SignUpPageAssignment
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
Automation automation = new Automation();
automation.TestMethod1();
}
}
}
包括用于
costura.fody的nuget包,破坏了我的xunit和nunit测试,在Visual Studio 2017的输出中给了我这个警告
在D:\Desktop\Code Projects\Product\App\Reporting UI\bin\x64\Debug\Report Generator.exe中,没有测试与给定的testcase筛选器FullyQualifiedName=Company.Product.Project.UnitTests.TestTestTest匹配
在VisualStudio201916.3.0预览版中,我甚至没有在输出窗口中看到它
删除costura后,我的单元测试再次运行。我遇到了一个稍微不同的问题——在我的项目中,我需要一个特殊的配置来运行单元测试,因为我使用ILMerge,并且在库类的版本之间出现冲突,其中一个被直接引用,另一个被ILMerge合并到我的测试代码中(据我所知,“内化”应该可以防止这种情况,但事实并非如此)
在我的例子中,我在尝试在“调试”配置下运行测试时遇到此错误。切换到自定义测试配置,现在我很好。其他人可能会遇到类似问题,他们需要在“调试”配置中“模式,但在VS中设置为处于发布配置。我的是System.Runtime软件包的一个问题。”。由于某种原因,它被降级为旧版本。我撤消了这个版本控制更改,现在测试运行程序工作正常
<package id="System.Runtime" version="4.3.1" targetFramework="net462" />
我也有同样的错误。对我来说,原因是缺少包:
NUnit.Engine
NUnit3TestAdapter
Microsoft.NET.Test.Sdk
MSTest.TestAdapter
MSTest.TestFramework
已通过为下一个软件包运行最新版本的更新,解决了“没有测试匹配给定的testcase筛选器FullyQualifiedName”的问题:
NUnit.Engine
NUnit3TestAdapter
Microsoft.NET.Test.Sdk
MSTest.TestAdapter
MSTest.TestFramework
我能够通过解决相同的错误消息。我必须进入测试->测试设置->默认处理器架构->x64。似乎我的设置与我的测试项目的平台目标不匹配。我的情况是-在新的VS2019中打开的NUnit 2.5的旧项目给出了相同的错误
由于默认情况下,VS2019中不包含NUnit 2.x,因此您需要安装它
转到菜单->扩展->管理扩展
然后搜索“NUnit 2测试适配器”
然后安装它
这对我很有帮助。我通过添加nuget包修复了这个问题:
MSTest.TestAdapter
对于XUnit,我可以通过添加“XUnit.runner.visualstudio”nuget包来解决这个问题。在Visual Studio 2019(v16.6.2)中,这些解决方案都不适合我
在“文本资源管理器”中,我可以看到我的测试,但当我右键单击它时,选择“运行”或“调试”,但它会安静地消失
在幕后,这件事已经结束了
No test is available in C:\MikesApp\bin\Debug\netcoreapp3.1\MikesApp.Tests.dll.
Make sure that test discoverer & executors are registered and platform &
framework version settings are appropriate and try again.
奇怪的是,如果我安装Resharper,并从“单元测试会话”窗口运行它,它会立即工作(?!!)
为什么我们在2021年仍然有这个问题(没有显示明确的错误消息 对于Visual Studio 2017,在安装“NUnit3TestAdapter”NuGet软件包后修复了上述错误
packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.CodeCoverage" version="16.8.0" targetFramework="net461" />
<package id="Microsoft.NET.Test.Sdk" version="16.8.0" targetFramework="net461" />
<package id="NUnit" version="3.12.0" targetFramework="net461" />
<package id="NUnit3TestAdapter" version="3.13.0" targetFramework="net461" />
<package id="Selenium.Support" version="3.141.0" targetFramework="net461" />
<package id="Selenium.WebDriver" version="3.141.0" targetFramework="net461" />
<package id="Selenium.WebDriver.ChromeDriver" version="89.0.4389.2300" targetFramework="net461" />
</packages>
似乎是单元测试的问题,而不是代码的问题。请参阅:@OlivierJacot Descombes:(1)错误与发布的代码有关:询问者在需要测试方法的地方放置了Main
方法,(2)你的链接指向NUnit,而询问者使用的是MSTest。观察良好的Luke!怎么用xUnit写字?哇!这解决了我的问题,谢谢你的回复。就是这样!仅添加Microsoft.NET.Test.Sdk、MSTest.TestAdapter。您将免费获得的最后一个:)