The Art of Unit Testing and TDD in Java

Recorded live during a three day class.

Video Error

We tried several times to play your video but there was an unforeseen error. We have notified our engineers.

Visit to check that Flash is enabled on your browser.

With Flash enabled, please try again in a few minutes or contact support.

  • Lectures 22
  • Video 3.5 Hours
  • Skill Level All Levels
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion

How taking a course works


Find online courses made by experts from around the world.


Take your courses with you and learn anywhere, anytime.


Learn and practice real-world skills and achieve your goals.

Course Description

Unit testing, done right, can mean the difference between a failed project and a successful one, between a maintainable code base and a code base that no one dares touch, and between getting home at 2 AM or getting home in time for dinner, even before a release deadline.

The Art of Unit Testing in Java course guides you step by step from simple tests to tests that are maintainable, readable, and trustworthy. It covers advanced subjects like mocks, stubs, and frameworks such as Mockito, Powermock and JMockit. And you'll learn about advanced test patterns and organization, working with legacy code and even untestable code.

What are the requirements?

  • Java and your favorite Java IDE

What am I going to get from this course?

  • Over 22 lectures and 3.5 hours of content!
  • Learn about readable, maintainable, trustworthy unit tests
  • Learn about Mocks, Stubs and Fakes and when to use which
  • Learn about Refactoring Techniques
  • Learn about Isolation (Mocking) Frameworks and how they differ

What is the target audience?

  • Developers of all levels

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.


Section 1: Day 1

We learn what does "Unit" in "Unit Test" mean, and what is the role of TDD in software development. We also learn about the three types of unit tests we can write: Return Value Tests, State Tests and Interaction Tests.


In this talk we start learning about JUnit and some of its APIs. We also learn when NOT to use some of them.


A short demo about jUnit basics.


A short demo showing Test Driven Development


What do I mean when I say "The simplest thing that could possibly work"?


Why not write many tests at once? Why start with a failing test? why solve things in the simplest way? These and many more questions are covered in this short talk.


How much time to you lose -- and save-- by using TDD? here are some numbers from my own experience.

Section 2: Day 2

In this talk we learn about mocks and stubs using a simple problem of notifying a logger of something that happened.


A short demo showing how you can implement the extract interface pattern, constructor injection and hand written mocks to solve our problem of controlling a 3rd party logger in a unit test.


Fake, Stub, Mock, Spy... what does it all mean? Let's talk about it.

6 pages

Use these drills during the course.


In this demo we look at a more detailed problem, where we would need a stub and a mock in the same test.


In this talk we learn about Isolation frameworks and how they try to help us avoid some of the problems that hand written mocks and stubs can create. Later we will also see sometimes Isolation frameworks hurt more than they help.


A short demo showing how you can capture the arguments sent to a mock object created with Mockito.

Section 3: Day 3

In this talk we learn about the Extract and Override Refactoring, and why it is one of the coolest things you should know.


Learn a simple technique to handle time in your tests, and in your production code.


How do you deal with objects being creating directly inside legacy code? We can refactor that!


In this talk we learn what frameworks such as Powermock and JMockit have to offer, both in terms of APIs and in terms of test readability and maintinability.


A quick demo showing how to make static methods throw errors with Powermock.


Is it really easier and simpler to write tests for legacy code using unconstrained frameworks in Java? Is it easier and simpler to refactor the code? Let`s talk about it.


In this talk we step back and look at our build process, and where the tests fit in it. We also talk about some best practices during builds.


Instructor Biography

Roy Osherove, Author of 'The Art Of Unit Testing'

I run TDD and team leadership classes for software developers.

Roy Osherove is one of the original ALT. NET organizers. He consults and trains teams worldwide on the gentle art of unit testing, test-driven development and how to lead software teams. He frequently speaks at international conferences on these topics and others.

Roy is the author of the book The Art of Unit Testing, and writes about subjects such as unit testing, TDD Team Leadership and agile development on his blog

Join the biggest student community


Hours of video content


Course Enrollments




Average Rating
  1. 5 Stars
  2. 4 Stars
  3. 3 Stars
  4. 2 Stars
  5. 1 Star
    • Bernard Łabno

    Detailed & practical

    Roy covers subject in great details with lots of practical examples. All his views are very well justified.
    This course really motivated me to do TDD.

    Thank you Roy!

    • Justin T

    Is this course worth the price?

    In summary this course feels like the teacher just uploaded a 3 day seminar he recorded without any additions to make it into a proper online course. All the lecture videos have had their audio fixed however, so you should be able to watch the lecture videos without a problem.

    Explained why testing is so important.
    Explained TDD.
    Talked about a couple of the popular testing frameworks.

    Hard to understand and therefore use the java drills given to practice what we learned from the videos.
    Needs better integration of the drills with the lecture videos.
    Can’t hear the questions from the students in the lecture videos.
    The slides from the class aren’t available, only the videos .
    Teacher does not response to questions about the course.

    Overall this course is not worth the price unless some changes are made. The teacher of this course is one of the top people in the field, so if he puts in some effort I’m sure this course can become worth 5 stars.

    • Lawrence C

    Very Poor Audio Quality

Ready to start learning?
Preview This Course