Let's check on a web page using C#, Visual Studio, NUnit, and Selenium Web Driver.
Visual Studio -> File -> New Project
Select C# Class Library
Name it StewShack.Web.UI.Tests
Rename Class1.cs to DefaultTest.cs
Let's add the [TestFixture] attribute to our DefaultTest class.
Adding the TestFixture attribute causes a compile-time error. To fix it, we need to bring in the NUnit package using NuGet. Right-click on the project and choose:
Manage NuGet Packages…
Search online for NUnit. Install it. You should now have references to the NUnit framework.
Now you can add the using statement for the NUnit.Framework namespace. Just put your cursor over the TestFixture attribute and press CTRL+. (control + period). This will pull up the Generate from Usage menu. Choose the first option to add the using statment.
Now we can add a test. I like to name my tests, [What is being tested]_[The action being taken]_[The expected result].
We cannot compile because we added code for Selenium without a reference. Manage Nuget packages and add Selenium WebDriver and Selenuim WebDriver Support Classes.
We added a Firefox driver, we need this driver to go to a page.
Running this test launches the home page of StewShack and immediately closes the browser.