Mockito Tutorial : Learn mocking with 25 Junit Examples
4.4 (229 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
3,346 students enrolled
Wishlisted Wishlist

Please confirm that you want to add Mockito Tutorial : Learn mocking with 25 Junit Examples to your Wishlist.

Add to Wishlist

Mockito Tutorial : Learn mocking with 25 Junit Examples

Learn unit testing and mocking with 25 Junit Examples
4.4 (229 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
3,346 students enrolled
Last updated 4/2017
English
Current price: $10 Original price: $40 Discount: 75% off
30-Day Money-Back Guarantee
Includes:
  • 4.5 hours on-demand video
  • 1 Article
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
What Will I Learn?
  • Use Mockito to write great unit tests
  • Understand the basics of unit testing
  • Understand how to use JUnit and Mockito together
View Curriculum
Requirements
  • You are expected to be familiar with Java
  • You are NOT expected to have any experience with Eclipse or Maven
  • We will help you install Eclipse and get up and running with Maven
Description

Writing great unit tests distinguishes good programmers from great programmers. In this course, you will learn how to write great unit tests with Mockito and JUnit.  You take 12 steps with JUnit and 18 steps with Mockito into unit testing proficiency.

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

  • 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

Who is the target audience?
  • Students who want to learn unit testing with Junit
  • Students who want to learn mocking with Mockito
  • We will help you install Eclipse and Maven
Curriculum For This Course
Expand All 37 Lectures Collapse All 37 Lectures 04:44:11
+
Introduction
2 Lectures 04:03
+
Unit Testing with JUnit
12 Lectures 01:21:56


Step 03 : First Successful JUnit. Green Bar and assertEquals
09:39

Step 04 : Refactoring Your First JUnit Test
07:44

Step 05 : Second JUnit Example assertTrue and assertFalse
14:45

Step 06 : @Before @After
07:02

Step 07 : @BeforeClass @AfterClass
03:30

Step 08 : Comparing Arrays in JUnit Tests
05:19

Step 09 : Testing Exceptions in JUnit Tests
03:33

Step 10 : Testing Performance in JUnit Tests
04:03

Step 11 : Parameterized Tests
11:11

Step 12 : Organize JUnits into Suites
03:24
+
Getting Ready for Mockito
2 Lectures 09:24
An Overview
01:53

Mockito Step 01 : Setting up a Maven Project
07:31
+
Need For Mockito
4 Lectures 43:49
Overview of this Section
02:10

Mockito Step 02 : Setting up SUT (System Under Test)
11:02

Step 03 : Stubbing Example - with Disadvantages of Stubbing
11:43

Step 04 : Your first Mockito code! Hurrah!!!
18:54
+
Mockito Basics
5 Lectures 45:12
Basics of Mockito - Section Overview
01:05

Step 05 : Stubbing variations with Mockito - Argument Matchers & More...
13:04

Step 06 : BDD Style - Given When Then
13:28

Step 07 : Verify calls on Mocks
08:52

Step 08 : Capturing arguments passed to a Mock
08:43
+
Mockito Advanced
6 Lectures 55:57
Step 09 : Hamcrest Matchers
11:41

Step 10 : Mockito Annotations - @Mock, @InjectMocks, @RunWith, @Captor..
10:00

Step 11 : Mockito Junit Rule
03:40

Step 12 : Real world Mockito Example with Spring
16:08

Step 13 : Mockito Spy
10:03

Step 14 : Theory : Why does Mockito not allow stubbing final & private methods?
04:25
+
Powermock with Mockito
6 Lectures 43:57
Step 15 : Setting up PowerMock and SystemUnderTest
08:37

Step 15 : Continued. Mocking Static Method
12:31

Step 16 : Invoking Private Methods
05:43

Step 17 : Mocking a Constructor
09:25

Step 18 : Writing Good Unit Tests
07:22

Bonus Lecture : Our Best Courses with 66,000 Students
00:19
About the Instructor
in28Minutes Official
4.3 Average rating
11,430 Reviews
75,766 Students
15 Courses
Popular Java Instructor - 52,000+ Students

About Me

I'm Ranga Karanam, an Architect with 15 Years of Java programming and design  with major banking clients across the world. 

We started in28Minutes with the aim to create Hands-on Courses with Real World Projects. Step-By-Step series of Courses is one of our creations.

About in28Minutes

We use Problem-Solution based Step-By-Step Hands-on Approach With Practical, Real World Application Examples.

While our primary expertise is on Development, Design & Architecture of Java & Related Frameworks (Spring, Spring MVC, Struts, Hibernate) we are expanding into the front-end world (Bootstrap, JQuery, Angular JS).

Our Beliefs

Best Courses are interactive and fun.

Foundations for building high quality applications are best laid down while learning.

Our Approach

We love open source and therefore, All our code is open source too and available on Github.

We use 80-20 Rule. We discuss 20% things used 80% of time in depth. We touch upon other things briefly equipping you with enough knowledge to find out more on your own.

Problem Solution based Step by Step Hands-on Learning.