Reputation: 407
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) ==========
Upvotes: 29
Views: 51079
Reputation: 417
I have the same issue. The problem for me was in the App.config.
If I exclude the App.config from the project the tests run!
In my case a section was not defined in configSections and the only visible consequence is that tests doesn't run
Upvotes: 0
Reputation: 7199
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
Upvotes: 30
Reputation: 26
Please set Default Process Architecture to X64. Once it is set you will be run tests. Test > Test Setting > Default Process Architecture > X64
Upvotes: 0
Reputation: 1559
For Visual Studio 2017, the above error fixed after installing "NUnit3TestAdapter" NuGet package.
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>
Upvotes: 4
Reputation: 143
In case of XUnit, I was able to resolve it by adding "xunit.runner.visualstudio" nuget package.
Upvotes: 11
Reputation: 401
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.
Upvotes: 21
Reputation: 1253
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.
Upvotes: 11
Reputation: 446
I had the same error. For me, the cause was missing packages:
NUnit.Engine
NUnit3TestAdapter
Upvotes: 8
Reputation: 918
Mine was an issue with System.Runtime package. It got downgraded for some reason to older version. I undo this versioning change and now test runner is working fine.
<package id="System.Runtime" version="4.3.1" targetFramework="net462" />
Upvotes: 3
Reputation: 3229
I had a slightly different issue -- in my project, I need a special configuration to run unit tests, as I use ILMerge and was getting a conflict between the versions of library classes, when one was referenced directly and one was ILMerged into my code under test (As far as I know, "Internalize" should prevent this, but it doesn't).
In my case, I got this error when trying to run tests under the "Debug" configuration. Switched to my custom Test configuration and now I'm good. Other people might have a similar issue where they need to be in the "Debug" mode, but are set in VS to be in Release configuration.
Upvotes: 0
Reputation: 604
Including the nuget package for costura.fody
broke both xunit and nunit tests for me, giving me this warning in the output in Visual Studio 2017
No test matches the given testcase filter FullyQualifiedName=Company.Product.Project.UnitTests.TestTestTest in D:\Desktop\Code Projects\Product\App\Reporting UI\bin\x64\Debug\Report Generator.exe
In the Visual Studio 2019 16.3.0 preview, I didn't even get that in my output window.
After removing costura, my unit tests run again.
Upvotes: 1
Reputation: 65054
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();
}
}
}
Upvotes: 14