This course will be retired on July 14, 2025.
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
Video Player
00:00
00:00
00:00
- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
By testing early in the software development process, we can avoid many problems down the road.
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
When coding, there's a powerful temptation
to do as little testing as possible or
0:00
to skip unit testing entirely.
0:04
We've all been there, we wanna get
the project coded as fast as possible, and
0:07
get it out the door so
we can impress our boss, or customer, or
0:10
just move on to the next thing.
0:14
With this mindset, proper testing
of the code is often overlooked.
0:16
We may figure that if it works properly
from the user's point of view,
0:21
then that's good enough, right?
0:23
Perhaps we should just test that.
0:26
This type of final product testing is
called functional black box testing.
0:28
Functional testing is an important
part of the testing process, but
0:33
let's consider what could happen when
we leave testing to the very end,
0:36
after most of the code is written.
0:40
What if while testing the final product,
0:43
we discover that the software
doesn't work as expected?
0:45
We'll need to find out
where the errant code is.
0:48
If the software has any
complexity to it at all,
0:51
then tracking down bugs deep in
the code can be very difficult.
0:54
Is a method or class coded incorrectly or
is the bug caused by the way a method or
0:58
class is used?
1:02
Perhaps there's a flaw in the way
the software is designed.
1:04
Let's say we finally find
where the bug is and fix it.
1:08
Mind you, that this may have required
rewriting large portions of the code.
1:12
Now we need to make sure that
the bug is actually fixed and
1:16
we didn't break anything in the process.
1:19
This means doing more functional testing.
1:22
Functional testing is very labor intensive
and can be very hard to automate.
1:26
It usually requires a human to
interact with the software and
1:30
try to break it just by using it.
1:34
It can be very difficult to try
every possible way that the software
1:36
may be used.
1:40
So, without automation, fixing and
retesting bugs can take a long time.
1:41
All this assumes that
there is some way for
1:47
a human to interact with the software
through some user interface.
1:49
Once all the code is written,
how long does it take to test it?
1:54
It's very difficult to predict how many
bugs will be found during testing, and
1:57
how long it will take to fix them?
2:02
This is a lot of uncertainty to
have at the end of a project.
2:04
Even when using the best software
development practices, there's
2:08
still a good deal of uncertainty which
has the potential to delay a project.
2:11
In software development time is money and
going over time means going over budget.
2:15
The purpose of unit testing
is to test early and often.
2:20
With unit testing, we test the code
at the same time we write it.
2:24
By doing this, we can be confident
that every unit is coded correctly
2:28
before we move on to
the next unit of code.
2:33
We can do this all the way up
to the end of the project.
2:35
This greatly reduces
the chances of finding bugs
2:39
after all of the code is written.
2:42
Even if we do find bugs
late in the process,
2:44
we can use the existing unit test to
narrow down where the bug is, and
2:46
we can write more unit tests to verify
that the issue has been resolved.
2:51
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