Automated ASP.NET MVC Testing: End to End

Learn how to test your ASP.NET MVC application at the model, controller, and view levels.
Course info
Rating
(335)
Level
Intermediate
Updated
Dec 2, 2014
Duration
3h 4m
Table of contents
Course Introduction
Testing the Model
Testing Controllers
Testing View Rendering
Automated Functional UI Testing
Running Tests on TeamCity Continuous Integration Server
Course Summary, Complimentary Techniques, and Further Learning
Description
Course info
Rating
(335)
Level
Intermediate
Updated
Dec 2, 2014
Duration
3h 4m
Description

This course covers what kind of tests to implement at each level of your ASP.NET MVC application, and how to run them using the TeamCity continuous integration server.

About the author
About the author

With over 15 years experience, Jason Roberts is a Microsoft .NET MVP, freelance developer, and author.

More from the author
Working with Files and Streams in C#
Intermediate
3h 13m
12 Oct 2018
Error Handling in C# with Exceptions
Intermediate
1h 37m
6 Aug 2018
More courses by Jason Roberts
Section Introduction Transcripts
Section Introduction Transcripts

Course Introduction
Hi. I'm Jason Roberts from Pluralsight. Welcome to this course on Automated ASP. NET MVC Testing: End to End. By the end of this course we will have learned how to apply testing to the different areas of our MVC application, so we'll learn how to test our model, our controllers, the rendering of our Razor Views, and how to write automated UI tests that actually drive the browser as if the user were using the application themselves. We'll also learn how to put all these tests together into TeamCity to produce a continuous integration build that runs all of our different tests at all of these different levels.

Testing the Model
Hi. Welcome back to this second module. In this module we'll be seeing how we can Test the Model of our MVC Application. So we'll be learning how to write Unit Tests for our model classes and also how to write Integration Tests that interact with an actual database. So our model is really the bedrock of our entire application. So it doesn't matter how well tested the other elements of the application are, if our model has got a serious business logic error in it, it's going to cause significant problems throughout the application. As we learned in the introductory module, our Unit Tests are really able to get into the nitty gritty of our model classes and make sure that they've got really test coverage.

Testing Controllers
Hi. Welcome back. In the previous module we learned how to write Classical and Mockist Style Unit Tests and then we implemented an Integration Test. In this module we're going to learn how to Test Controllers, Specifically we'll learn how to write tests that confirm controller actions or behaving as expected. This includes things like testing that an action returns the correct view or HTTP status code. We're going to start by trying to create a test manually and then refactor it to be more readable and maintainable. So let's kick off this module by thinking about some of the things we may want to test in our controllers.

Testing View Rendering
Hi. Welcome back. In the previous module we looked at some ways we can test our controller actions. In this module we're going to take a closer look at our views. So we're going to see how we can take our Razor Views and actually instantiate them in our Unit Tests and then perform tests against them. So, for example, to check that a model item is being rendered in the correct place or that any view logic is operating as expected.

Automated Functional UI Testing
Hi. Welcome back. In the previous module we learned how we can test our Razor Views in isolation from the rest of the system. In this module we're going to see how we can write Automated Functional User Interface Tests. So these tests will actually work through the browser as if a real user was using our application. So in this way we're not writing isolated tests anymore, we're writing tests that can potentially touch all layers of the application, right from the user interface, right down to the database.

Running Tests on TeamCity Continuous Integration Server
Hi. Welcome back. So now we've defined the tests at the different levels so we've got our Controller tests, our Unit tests, our Integration tests, and our View Rendering tests, in addition to our Automated Functional UI tests. We can now go and set up a build on a Continuous Integration Server, to build not only the Banking Site, but also all of the tests and then execute these tests in a central place on our Integration Server. This means that anytime anyone checks in any new code, all of the tests will be executed and we'll find out if anything is broken. (Loading)

Course Summary, Complimentary Techniques, and Further Learning
Hi. Welcome back to this final module. In this module we're going to get a Summary of some of the things we've learned throughout the course, we're going to look at a few Complimentary Techniques that you may wish to investigate, and we'll finish up with some Further Learning resources. So let's start off this module with a Summary of some of the things we've learned.