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
With unit testing we test each unit of code independently.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
[MUSIC]
0:00
Hello and welcome to Unit Testing in C#.
0:05
One of the keys to creating quality
software is testing it thoroughly.
0:08
There are many ways to test software.
0:13
While you may have some idea of
what it means to test software.
0:15
You may not be familiar with unit testing.
0:19
Unit testing is considered an essential
part of the software development process.
0:21
And it's the type of testing that software
developers are most involved with.
0:26
Because it requires an intimate
knowledge of the code being tested.
0:30
In unit testing,
we look at our code one unit at a time and
0:34
test that unit thoroughly to
verify that it works as expected.
0:38
When solving a problem, it's always easier
to split the problem up into smaller parts
0:42
and solve each of the sub problems first.
0:47
This is the key to designing software.
0:50
Just one of the many benefits
of designing software this way
0:53
is that we can then verify that each of
the sub problems has in fact been solved.
0:56
And we can test them independently
from the rest of the software.
1:01
Once we've completed our test,
we can be confident that the code for
1:05
solving that problem will work as expected
when combined with the rest of the system.
1:09
This is why this type of
testing is called unit testing.
1:15
We test each unit of code independently.
1:18
You may be wondering what
is considered a unit?
1:22
There is no set definition
of what a unit is.
1:25
It often depends on how
the software is architected and
1:28
which programming language is used.
1:31
In object oriented programming in C#, each
class is typically considered a unit but
1:33
a unit could be something as
small as a single method.
1:39
When designing and coding, we break up
the software into units of responsibility.
1:41
For example think about the list
class provided by .NET.
1:46
It can be thought of as a single unit.
1:51
In order to verify that the list
class does what's expected,
1:53
we need to test each and every
operation that the list class provides.
1:57
This means testing to make sure that
every method in it works properly.
2:02
When designing software,
we need to design it to be unit testable.
2:06
This means splitting it
up into composable parts.
2:10
Fortunately, following good object
oriented design principles makes your code
2:14
unit testable at the same time.
2:18
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up