
Jason Roberts
Welcome to Part 5 of this review of the Pluralsight course Automated ASP.NET MVC Testing: End to End by Jason Roberts.
With over 15 years industry experience, Jason is a Microsoft .NET MVP who has has written multiple books including Clean C#, and C# Tips. He is also an open source contributor and the creator of FeatureToggle.
Automated Functional UI Testing
What Is Automated Functional UI Testing?
Automated Functional UI Testing allows us to test the whole application as if an end-user were using the system.
It is not about testing the visual or stylistic aspects, instead we focus on the functional aspects of the system.
It can be the last line of defense for finding bugs before releasing into production.
A failing automated functional UI test may be an indication that there are missing unit tests.
Benefits and Drawbacks
Jason begins with the benefits:
They allow us to test a broad selection of the application subsystems and classes, and test that the parts are wired together correctly.
Automated Functional UI testing is also known as Black Box testing – we are not concerned with the actual implementations, only whether they work.
There’s almost no cost to running these tests as often as we want, and it can liberate human testers from repetitive testing work, so that they can work on more interesting and creative testing work.
Jason also covers the drawbacks, and there are several.
UI Automation Overview
Jason describes the relationship between UI Tests, the Browser Automation Library, the Browser, and the Web Server.
Introducing Seleno
Seleno is written by TestStack, the same authors as the Fluent MVC Testing library. It is built on top of the Selenium Browser Automation Framework. By default, Selenium acts on the Firefox browser.
Getting Started
In this demo we:
- Install the relevant NuGet packages: NUnit, TestStack.Seleno and Microsoft.AspNet.Mvc
- Update the version of the Selenium NuGet package that gets installed by Seleno: update-package Selenium.WebDriver
- Look at the BrowserHost class, which contains a static instance of SelenoHost, and runs our BankingSite app on the specified port
Creating Simple Automated Test Scripts
In this demo we:
- Automate the loan application process
- Test that the applicant has been accepted
- See Firefox being automated
- Write a second test for being declined and notice the code duplication involved
There is a lot of boilerplate code making it difficult to read the code effectively.
Page Object Model Overview
The Page Object Model sits between our UI Tests and the Browser Automation Library, giving us a layer of abstraction and hopefully cleaner and simpler UI Tests.
Seleno promotes the use of Page Object Models.
Refactoring to Use Page Object Models
In this demo we see:
- How to define page object models
- How to refactor our accept and decline tests to simplify our test code
Strongly Typed Page Object Models
Now we’ve refactored our initial test scripts to use Page Object Models, we can reduce the amount of test code even further by using Strongly Typed Page Object Models.
Digging Deeper into Seleno
Jason Roberts has authored another course that digs deeper into Seleno: Building the Right Thing in .NET with TestStack (published May 2014)
John Sonmez also has a couple of Pluralsight courses on testing with (vanilla) Selenium that you may be interested in, e.g. Creating an Automated Testing Framework With Selenium (published Sep 2013)