Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
Unit test frameworks make unit testing much easier.
Support for Visual Studio 2017
The xUnit.net Test Extensions Visual Studio extension currently only supports Visual Studio 2015. If you're using Visual Studio 2017, you can install the xUnit.net.TestGenerator Visual Studio extension which provides similar functionality.
See these links for more information:
- https://marketplace.visualstudio.com/items?itemName=YowkoTsai.xUnitnetTestGenerator
- https://github.com/yowko/xUnit.net.TestGenerator
Testing Frameworks
Over the years, many tools have been
developed to make unit testing easier.
0:00
A unit test is simply a method that
executes the code under test and
0:05
checks to see if it got
the expected results.
0:08
We could do this right from the main
method of a console application.
0:11
However, after writing many unit tests,
0:15
you'd start to see a pattern in how
these tests are set up and run.
0:17
You'd eventually create a framework
that all of your unit tests can use.
0:20
Fortunately, there are many such
frameworks already available for .NET.
0:25
There are three main frameworks.
0:29
MSTest which is also known as
the Visual Studio Unit Testing Framework,
0:31
NUnit and xUnit.net.
0:36
All three of these frameworks
are based off of one of the first
0:40
popular unit testing frameworks for
Java called jUnit.
0:44
They all work relatively the same, though.
0:48
Together these frameworks and
0:50
others like them are referred to as
the xUnit family of unit test frameworks.
0:52
Of these three frameworks for .NET,
xUnit.net is the most popular and
0:57
the one that has the most
active development.
1:02
It's also the one we'll
be using in this course.
1:05
You may work on projects that use one of
the other frameworks and that's okay.
1:08
Everything you'll learn in
this course can be applied
1:13
to any of this family of
unit testing frameworks.
1:15
That said you'll often hear me
refer xUnit.net as just xUnit.
1:18
Just know that I'm only
referring to xUnit.net and
1:24
not the family of frameworks as a whole.
1:27
One great thing about unit testing
frameworks is that they often work
1:30
well with IDEs such as Visual Studio,
which means we can execute,
1:33
debug, and get the results of our
unit test without leaving the IDE.
1:38
To do that, we'll want to install
an extension to Visual Studio.
1:42
The Outercurve Foundation,
1:46
which is one of the open source
companies supported by Microsoft,
1:49
has made using xUnit.net really easy by
creating an extension to Visual Studio.
1:52
This extension helps with generating
test projects that come complete with
1:58
everything we need to create and
run tests.
2:01
To install it, just click Tools,
Extensions and Updates.
2:04
Now over here click on Online.
2:10
Over in the search box,
just type in xunit.
2:13
Here we see a number of extensions and
templates that have to do with xUnit.
2:18
The one we want is called
xUnit.net Test Extensions.
2:22
It's created by Outercurve Foundation.
2:27
I just click Download here to install it.
2:30
You may have to click the Restart Now
button to restart Visual Studio to enjoy
2:35
this extension.
2:38
There we go, that's all we need to do.
2:41
We'll take a closer look at what this
extension does for us in the next video.
2:43
You need to sign up for Treehouse in order to download course files.
Sign up