Tests not appearing in Visual Studio test explorer

Viewed 3172

I'm having issues setting up my tests. I have tried using a console c# file for my selenium tests which runs the test however it doesn't appear in the test explorer. When I create a unit test c# project it doesn't run or show up in the test explorer. What have done wrong?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SeleniumTests1
{
    [TestClass]
    class SeleniumTest
    {
        [TestMethod]
        static void Main(string[] args)
        {

            IWebDriver driver = new FirefoxDriver();
            driver.Navigate().GoToUrl("http://www.bing.com/");
            driver.Manage().Window.Maximize();

            IWebElement searchInput = driver.FindElement(By.Id("sb_form_q"));
            searchInput.SendKeys("Hello World");
            searchInput.SendKeys(Keys.Enter);

            searchInput = driver.FindElement(By.Id("sb_form_q"));
            string actualvalue = searchInput.GetAttribute("value");

            Assert.AreEqual(actualvalue, "Hello World");
            driver.Close();
        }
    }
}
4 Answers

Although this one's a rather obvious and straightforward answer, but, looking at the code posted originally by Peter and my own silly mistake I realized that one more place where we can go wrong is by not making our outer test class public without which they would default to internal and the contained tests would not show up in the test explorer. So, the final form of a unit test code would begin with something like this

namespace SeleniumTests1
{
  [TestClass]
  public class SeleniumTest
  {
    [TestMethod]
    public void testMethod(string[] args)
    {
Related