Unit testing your code is all about being able to confidently test one particular piece of code without worrying about dependencies causing problems. If you get a failure in a unit test, you can to be sure that the failure was caused by bad code INSIDE of the unit of code you were testing (not because some dependency has failed)
What you'll Learn
In this episode you'll hear all about these things called “dependencies” and how they can be minimized by using mocking.
You'll learn what mocking does to Objects in your unit tests.
You'll learn what kinds of frameworks exist out there and how you can obtain them for you own personal use… don't worry, they're all free!
You will also learn just how powerful these mocking frameworks are in what they allow you to do with methods of dependent classes… really, really cool stuff guys/gals.
Links Mentioned in the Show
Here's a list of the links that I mentioned in the show:
- Mockito – Grab the JAR file here
- PowerMock – Can be used WITH Mockito to extend the functionality of your unit tests (i.e. mocking static/final methods)
- jMock – Another mocking library (just like Mockito). I've never used it, but it's another popular choice for mocking!
Listener Questions
We had a question come in from a listener who wanted to know what they could do to gain some real world experience without having to work a full-time job as either an entry level developer or an intern. You can hear all my comments on how I think this can be achieved in the last part of this podcast episode, so be sure not to miss it, as I'm sure this topic applies to MANY of you out there today :)
As always, if you do have any questions for me to answer on the podcast, feel free to shoot me an email and let me know you want the question answered on the Podcast. Be sure to leave your name so I can mention you!