Automated ASP.NET MVC Testing: End to End

jasonroberts

Jason Roberts

Welcome to 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.

Also in this series:

Part 1 – Automated ASP.NET MVC Testing

Part 2 – Testing the Model

Part 3 – Testing Controllers

Part 4 – Testing View Rendering

Part 5 – Automated Functional UI Testing

Part 6 – Running Tests on TeamCity Continuous Integration Server

Part 7 – Further Learning

 

Automated ASP.NET MVC Testing: End to End

Why Quality?

Jason explains the reasons why we should always aim for high quality:

  • Happier end users
  • Happier development team
  • Happier business owners

Why Automated Testing?

Jason compares manual human test scripts against automated tests.

Automated Tests are less error prone, are faster to execute, and are virtually free to run. These tests also live alongside the source code.

Automated Tests Are Part of the Quality Story

Other important pieces of the Quality story are:

  • Code reviews
  • Pair programming
  • Good management
  • Motivated development team
  • Well understood requirements
  • Good configuration management
  • Don’t replace all manual human testing

The Automated Testing Pyramid

At the top of the pyramid we have fewer tests, which take longer to execute and are more brittle and a broad reach.

At the bottom of the pyramid we have more tests, which are fast to execute, less brittle and a narrow reach.

Jason explains we can achieve this with three separate categories of automated tests:

  • UI – automating the user interface
  • Integration – multiple less-related classes
  • Unit – tests a single class, or a few closely related classes

What is a Unit Test?

  • low level and highly focused
  • isolated from the rest of the system
  • fast to execute

We see this great quote from Martin Fowler:

…it’s a situational thing – the team decides what makes sense to be a unit for the purposes of their understanding of the system and its testing.

Unit Testing Isolation Styles

We have the classical approach, and the mockist approach, and Jason explains the differences between the two.

In the classical style we only use fake collaborators when it becomes difficult to use real collaborators. The mockist style uses fake collaborators by default.

There is a famous article from Martin Fowler called Mocks Aren’t Stubs which explains these differences in full.

Naming Convention: SUT

SUT is an acronym which stands for System Under Test. In this course, it is used to represent the class that is currently being tested.

Course Structure

After this introductory module, there are a further six modules, and Jason gives a brief overview of each of them here.

Demo ASP.NET MVC Application Overview

Jason shows a BankingSite application in Visual Studio. We see the main directories of interest:

  • Controllers
  • Models
  • Views

He runs it up and we see that it is a Bootstrap application that initially looks a lot like the default sample application.

There’s a page for entering your details for applying for a loan. When we click the Apply button we get an accepted or declined page, and we get a reference number.

There’s also a search facility where we can enter our reference number.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s