Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Unit Testing in Java!
You have completed Unit Testing in Java!
Preview
It is a great idea to verify that exceptions are thrown in your code when you intend them to. They are part of your happy path. Let's go catch some!
FIRST
- Fast. Like super fast, or they won't be run.
- Isolated. Make sure you are only testing what you intend to test.
- Repeatable. Every test run should return the same results. Be careful of time and intermittent failures. Over-specifying expectations are usually a sign of possible breakage.
- Self-verifying. If tests are passing, you should feel safe that things are good to go to production. If they are failing, you should fix them, and trust that something indeed is broken. Trust trust trust.
- Timely. Write tests either before or as you write code. Don't fall behind!
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
them to, let's take a quick look at
another testing mnemonic device.
0:00
The first rule to writing
a good test is this.
0:02
Tests should be fast.
0:06
If they don't run fast, the more likely
it is the developers won't run them.
0:08
Unit tests will run fast because
they should be isolated.
0:13
You should not be relying on other code.
0:17
You should use test doubles to make sure
that you are only running the code that
0:19
you are testing.
0:22
We'll talk more on this in a bit.
0:24
You always wanna make sure
that your test is repeatable.
0:26
You should get the same results
every time you run the test.
0:29
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