Learn Java Unit Testing with Junit & Mockito in 30 Steps

4h 44m 35s
English
Paid

Course description

Learn Mockito and JUnit - the most popular Java unit testing and mocking frameworks - with 25 Examples. Writing Great Unit Tests distinguishes Good Programmers from Great Programmers. In this course, you will learn how to Write Great Java Unit Tests with Mockito and JUnit.
Read more about the course

You take 12 steps with JUnit and 18 steps with Mockito into unit testing proficiency.

Mocking with Mockito

  • Step 01 : Set up an Eclipse Project with JUnit and Mockito frameworks. First Green Bar.

  • Step 02 : Example to start understanding why we need mocks.

  • Step 03 : What is a stub? Create an unit test using Stub? Disadvantages of Stubs.

  • Step 04 : Your first Mockito code! Hurrah!!! Lets use Mockito to mock TodoService.

  • Step 05 : Stubbing variations with Mockito. A few mockito examples mocking List class : Multiple return values, Argument Matchers and throwing exceptions.

  • Step 06 : Introduction to BDD. Given When Then. BDD Mockito Syntax.

  • Step 07 : How to verify calls on a mock? Verify how many times a method is called. We will add deleteTodo method to the TodoService.

  • Step 08 : How to capture an argument which is passed to a mock?

  • Step 09 : Hamcrest Matchers.

  • Step 10 : Let's simplify things with Mockito Annotations. @Mock, @InjectMocks, @RunWith(MockitoJUnitRunner.class), @Captor

  • Step 11 : JUnit Rules. Using MockitoJUnit.rule() instead of @RunWith(MockitoJUnitRunner.class).

  • Step 12 : Real world Example with Spring

  • Step 13 : What is a spy? How to spy with Mockito?

  • Step 14 : Some Theory : Why does Mockito not allow stubbing final and private methods?

  • Step 15 : Using PowerMock and Mockito to mock a Static Method.

  • Step 16 : Using PowerMock and Mockito to invoke a private Method.

  • Step 17 : Using PowerMock and Mockito to mock a constructor.

  • Step 18 : Good Unit Tests.

JUnit Framework

  • Step 01 : Need for Unit Testing

  • Step 02 : Setting up your First JUnit

  • Step 03 : First Successful JUnit. Green Bar and assertEquals

  • Step 04 : Refactoring Your First JUnit Test

  • Step 05 : Second JUnit Example assertTrue and assertFalse

  • Step 06 : @Before @After

  • Step 07 : @BeforeClass @AfterClass

  • Step 08 : Comparing Arrays in JUnit Tests

  • Step 09 : Testing Exceptions in JUnit Tests

  • Step 10 : Testing Performance in JUnit Tests

  • Step 11 : Parameterized Tests

  • Step 12 : Organize JUnits into Suites

Watch Online

This is a demo lesson (10:00 remaining)

You can watch up to 10 minutes for free. Subscribe to unlock all 36 lessons in this course and access 10,000+ hours of premium content across all courses.

View Pricing

Watch Online Learn Java Unit Testing with Junit & Mockito in 30 Steps

0:00
/
#1: Introduction

All Course Lessons (36)

#Lesson TitleDurationAccess
1
Introduction Demo
02:19
2
Three thing you need to know
01:46
3
JUnit Step 1 : Why is Unit Testing Important?
03:42
4
JUnit Step 2 : Setting up your first JUnit
08:06
5
Step 03 : First Successful JUnit. Green Bar and assertEquals
09:40
6
Step 04 : Refactoring Your First JUnit Test
07:45
7
Step 05 : Second JUnit Example assertTrue and assertFalse
14:46
8
Step 06 : @Before @After
07:03
9
Step 07 : @BeforeClass @AfterClass
03:31
10
Step 08 : Comparing Arrays in JUnit Tests
05:20
11
Step 09 : Testing Exceptions in JUnit Tests
03:34
12
Step 10 : Testing Performance in JUnit Tests
04:04
13
Step 11 : Parameterized Tests
11:12
14
Step 12 : Organize JUnits into Suites
03:25
15
An Overview
01:54
16
Mockito Step 01 : Setting up a Maven Project
07:32
17
Overview of this Section
02:11
18
Mockito Step 02 : Setting up SUT (System Under Test)
11:03
19
Step 03 : Stubbing Example - with Disadvantages of Stubbing
11:44
20
Step 04 : Your first Mockito code! Hurrah!!!
18:55
21
Basics of Mockito - Section Overview
01:06
22
Step 05 : Stubbing variations with Mockito - Argument Matchers & More...
13:05
23
Step 06 : BDD Style - Given When Then
13:29
24
Step 07 : Verify calls on Mocks
08:53
25
Step 08 : Capturing arguments passed to a Mock
08:44
26
Step 09 : Hamcrest Matchers
11:42
27
Step 10 : Mockito Annotations - @Mock, @InjectMocks, @RunWith, @Captor..
10:01
28
Step 11 : Mockito Junit Rule
03:41
29
Step 12 : Real world Mockito Example with Spring
16:09
30
Step 13 : Mockito Spy
10:04
31
Step 14 : Theory : Why does Mockito not allow stubbing final & private methods?
04:26
32
Step 15 : Setting up PowerMock and SystemUnderTest
08:38
33
Step 15 : Continued. Mocking Static Method
12:32
34
Step 16 : Invoking Private Methods
05:44
35
Step 17 : Mocking a Constructor
09:26
36
Step 18 : Writing Good Unit Tests
07:23

Unlock unlimited learning

Get instant access to all 35 lessons in this course, plus thousands of other premium courses. One subscription, unlimited knowledge.

Learn more about subscription

Comments

0 comments

Want to join the conversation?

Sign in to comment

Similar courses

RESTful Web Services, Java, Spring Boot, Spring MVC and JPA

RESTful Web Services, Java, Spring Boot, Spring MVC and JPA

Sources: udemy
This video course also covers the H2 in-memory database and teaches how to build RESTful Web Service that stores data in a database without a need to install My
25 hours 8 minutes 11 seconds
Java Test Automation Engineer - from Zero to Hero

Java Test Automation Engineer - from Zero to Hero

Sources: udemy
Are you ready to embark on an exciting journey to become a Test Automation Hero in Java? Whether you're new to programming or have some experience, this course
18 hours 40 minutes 6 seconds
Java Design Patterns & SOLID Design Principles

Java Design Patterns & SOLID Design Principles

Sources: udemy
This course starts with SOLID Design Principles in Java. It will then provide a comprehensive introduction to Java Design patterns with practical, hands on exercises. This cour...
17 hours 5 minutes 6 seconds
The Ultimate Data Structures & Algorithms: Part 2

The Ultimate Data Structures & Algorithms: Part 2

Sources: codewithmosh (Mosh Hamedani)
Data structures and algorithms are patterns for solving problems. Developers who know more about data structures and algorithms are better at solving problems. That’s why compan...
5 hours 56 minutes 46 seconds
Microservices: Clean Architecture, DDD, SAGA, Outbox & Kafka

Microservices: Clean Architecture, DDD, SAGA, Outbox & Kafka

Sources: udemy
Hi there! My name is Ali Gelenler. I'm here to help you learn microservices architecture while applying Clean and Hexagonal Architectures and using Domain Drive
18 hours 2 minutes 34 seconds