Course

Mockito & Java Unit Testing

Learn unit testing in Java using Mockito. Master mocking, verification, argument capturing, and advanced test design for real-world applications.

of video
2 h
lectures
42
sections
9

$99.97one payment

Lifetime access. 15-day money-back guarantee.

Want a mentor as well? The Academy gives you every course on Amigoscode plus code reviews, daily live calls and interview prep, for $129/month. Compare →

What you'll learn

By the end of this course

  • Mocking Basics - Understand how and why we use mocks in Java applications.
  • Creating Mocks - Learn to create and inject mock dependencies using Mockito.
  • Stubbing Methods - Control mock behavior with when() and return values.
  • Verifying Interactions - Use verify(), verifyNoInteractions(), and more to assert mock behavior.
  • Argument Capturing - Capture and assert arguments passed to mocked methods.
  • BDD with Mockito - Apply Behavior-Driven Development (BDD) using given() and then().
  • Advanced Techniques - Learn custom answers, async verification, and in-order assertions.
  • Mocking Time - Control time in your tests with mock clocks and scheduled verifications.

Curriculum

9 sections, 42 lectures

2 h of video. Open any section to see its lectures.

1Intro4 min
  1. 1Recommended CoursesFree preview
  2. 2Introduction To MocksFree preview4 min
2Environment setup18 min
  1. 1Create ProjectFree preview4 min
  2. 2Installing MockitoFree preview3 min
  3. 3Your First MockFree preview10 min
  4. 4Fix WarningFree preview2 min
3Core concepts27 min
  1. 1SetupFree preview3 min
  2. 2Why Do We Need MocksFree preview6 min
  3. 3Stubbing Methods Using When()4 min
  4. 4Verifying Method Calls With Verify()3 min
  5. 5Different Ways To Init Mocks5 min
  6. 6Matchers7 min
  7. 7Quiz
4Verify interactions21 min
  1. 1Verify No Interactions2 min
  2. 2Verify No More Interactions3 min
  3. 3Verification Modes4 min
  4. 4Implement Order And Repository Classes4 min
  5. 5Change Order Service3 min
  6. 6Fix And Adding Tests3 min
  7. 7Should Throw When Charge Fails3 min
  8. 8Quiz
5Capturing arguments13 min
  1. 1Assert Argument8 min
  2. 2Argument Captors6 min
  3. 3Quiz
6Advanced techniques18 min
  1. 1Mockito BDD6 min
  2. 2Chaining Return Values2 min
  3. 3Return Custom Answer3 min
  4. 4In Order3 min
  5. 5Async Behaviour And Timeout()3 min
  6. 6Quiz
7Control clock20 min
  1. 1Mocking Clock7 min
  2. 2Verification Code Example4 min
  3. 3Exercise
  4. 4Solution Part 14 min
  5. 5Solution Part 25 min
8Exercise1 min
  1. 1Part 1 - Create Product Record or Class
  2. 2Part 2 - Create Product Repository Interface
  3. 3Part 3 - Create Product Service Class
  4. 4Part 4 - Write the tests
9Outro1 min
  1. 1Outro
  2. 2Feedback
  3. 3Next and Recommended Courses

Choose how you learn

Learn on your own, or with people who check your work

The course is yours to keep. The Academy is this course and every other one, plus the people who get you hired.

Mockito & Java Unit Testing

The course, on your own

$99.97one payment

  • 42 lectures, 2 h of video
  • Source code for everything you build
  • Course slides to revise from
  • Subtitles on every video
  • 6 months of IntelliJ IDEA Ultimate
  • Lifetime access to the course and its updates

15-day money-back guarantee

Recommended

The Academy

The courses, plus the people

$129/monthcancel anytime

This course, plus

  • Every course on Amigoscode 50+ in the Zero to Hired Roadmap
  • Daily live calls and 1:1 instructor time
  • Code reviews and pair programming on what you build
  • Interview prep mock interviews, System Design Lab, CV and LinkedIn review
  • Land an interview in 90 days or we coach you 1:1 free until you do.
Join the Academy

7-day money-back guarantee · Secure checkout on Skool

“Nelson was teaching 90% of my job. I was already implementing everything I learnt from it.”
MBMarlon BragaJava Full Stack Software Developer
“I was a totally different person. More confident as a developer, more prepared for my job.”
GabrielaSoftware Engineer at Mercado Livre
“I studied biomedicine and psychology. I found Nelson's Java tutorials while looking for a course for my brother. I was hooked and now here I am, a software engineer at IKEA.”
NajmaSoftware Engineer at IKEA

Read every review →

About this course

Who is this course for?

Level: All (Mid and Senior Engineers). Watch the free preview lectures in the curriculum to see if it's right for you.

How long will it take?

There are about 2 hours of video. Most people finish in a week at 5 hours a week, plus the time you spend building along.

Do I keep access?

Yes. You pay once and keep the course for life, including updates.

What if it isn't for me?

Email us within 15 days of buying and we'll refund you in full.

Should I buy the course or join the Academy?

Buy the course if you only want this topic and you learn well on your own. Join the Academy if you want to get hired or move up: you get every course on Amigoscode, this one included, plus daily live calls, code reviews and interview prep, for $129/month. The course is $99.97 once.