Udemy
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Development
Web Development Data Science Mobile Development Programming Languages Game Development Database Design & Development Software Testing Software Engineering Development Tools No-Code Development
Business
Entrepreneurship Communications Management Sales Business Strategy Operations Project Management Business Law Business Analytics & Intelligence Human Resources Industry E-Commerce Media Real Estate Other Business
Finance & Accounting
Accounting & Bookkeeping Compliance Cryptocurrency & Blockchain Economics Finance Finance Cert & Exam Prep Financial Modeling & Analysis Investing & Trading Money Management Tools Taxes Other Finance & Accounting
IT & Software
IT Certification Network & Security Hardware Operating Systems Other IT & Software
Office Productivity
Microsoft Apple Google SAP Oracle Other Office Productivity
Personal Development
Personal Transformation Personal Productivity Leadership Career Development Parenting & Relationships Happiness Esoteric Practices Religion & Spirituality Personal Brand Building Creativity Influence Self Esteem & Confidence Stress Management Memory & Study Skills Motivation Other Personal Development
Design
Web Design Graphic Design & Illustration Design Tools User Experience Design Game Design Design Thinking 3D & Animation Fashion Design Architectural Design Interior Design Other Design
Marketing
Digital Marketing Search Engine Optimization Social Media Marketing Branding Marketing Fundamentals Marketing Analytics & Automation Public Relations Advertising Video & Mobile Marketing Content Marketing Growth Hacking Affiliate Marketing Product Marketing Other Marketing
Lifestyle
Arts & Crafts Beauty & Makeup Esoteric Practices Food & Beverage Gaming Home Improvement Pet Care & Training Travel Other Lifestyle
Photography & Video
Digital Photography Photography Portrait Photography Photography Tools Commercial Photography Video Design Other Photography & Video
Health & Fitness
Fitness General Health Sports Nutrition Yoga Mental Health Dieting Self Defense Safety & First Aid Dance Meditation Other Health & Fitness
Music
Instruments Music Production Music Fundamentals Vocal Music Techniques Music Software Other Music
Teaching & Academics
Engineering Humanities Math Science Online Education Social Science Language Teacher Training Test Prep Other Teaching & Academics
AWS Certification Microsoft Certification AWS Certified Solutions Architect - Associate AWS Certified Cloud Practitioner CompTIA A+ Cisco CCNA Amazon AWS AWS Certified Developer - Associate CompTIA Security+
Photoshop Graphic Design Adobe Illustrator Drawing Digital Painting InDesign Character Design Canva Figure Drawing
Life Coach Training Neuro-Linguistic Programming Mindfulness Personal Development Personal Transformation Meditation Life Purpose Coaching Neuroscience
Web Development JavaScript React CSS Angular PHP WordPress Node.Js Python
Google Flutter Android Development iOS Development Swift React Native Dart Programming Language Mobile Development Kotlin SwiftUI
Digital Marketing Google Ads (Adwords) Social Media Marketing Google Ads (AdWords) Certification Marketing Strategy Internet Marketing YouTube Marketing Email Marketing Retargeting
SQL Microsoft Power BI Tableau Business Analysis Business Intelligence MySQL Data Analysis Data Modeling Big Data
Business Fundamentals Entrepreneurship Fundamentals Business Strategy Online Business Business Plan Startup Freelancing Blogging Home Business
Unity Game Development Fundamentals Unreal Engine C# 3D Game Development C++ 2D Game Development Unreal Engine Blueprints Blender
30-Day Money-Back Guarantee

This course includes:

  • 3 hours on-demand video
  • 2 articles
  • Full lifetime access
  • Access on mobile and TV
Development Software Engineering Unit Testing

JUnit and Mockito Unit Testing for Java Developers

Master how to use JUnit to unit test Java applications using JUnit, Mockito and Hamcrest!
Rating: 4.3 out of 54.3 (23 ratings)
141 students
Created by Matt Speake, Java Easily
Last updated 4/2020
English
English [Auto]
30-Day Money-Back Guarantee

What you'll learn

  • Be able to write unit tests confidently using JUnit
  • Appreciate mocking and mock objects and understand how to test interactions with Mockito
  • Be able to use Mockito to create test fixtures, stub methods by programmatic and annotation-driven test setup
  • Understand how to analyse production code to guide writing unit tests
  • Gain an appreciation of the JUnit Assertions API and be able to write assertions using that and Hamcrest, the popular assertions library shipped with JUnit
  • Understand modern unit testing concepts and best practices

Course content

7 sections • 68 lectures • 2h 58m total length

  • Preview01:27
  • How to get help and support
    01:26
  • Preview01:34
  • A quick welcome and note on the course format
    00:34

  • Section introduction
    00:49
  • What is Unit Testing?
    02:45
  • What is JUnit?
    03:40
  • Preview03:02
  • Preview05:08
  • Conventions for Writing Unit Tests
    02:41
  • Characteristics of Proper Unit Tests
    05:48
  • What are Assertions?
    07:50

  • Section introduction
    00:36
  • Preview02:51
  • Introducing a typical Java project structure (production vs test source trees)
    02:47
  • Understanding the basic conventions for creating unit tests (package and naming
    03:42

  • Section introduction
    00:52
  • Preview01:39
  • Running a unit test within the IDE and understanding test success
    01:21
  • Understanding test failures with exceptions
    02:21
  • Failing a unit tests explicitly with Assert.fail
    00:45
  • Using Assert.fail to check validation logic in a try/catch
    02:23
  • An introduction to the JUnit Assertions API
    01:54
  • Structuring unit tests with Arrange/Act/Assert
    02:04
  • Understanding execution of assertions and JUnit's fail-fast test failure mechani
    03:28
  • Adding descriptive comments to assertions and test failures to aid diagnostics
    00:48
  • Coding a unit test following Arrange-Act-Assert
    01:12
  • Keeping test setup DRY with @Before
    04:56
  • Understanding test fixture instantiation
    02:14

  • Section introduction
    01:12
  • Preview03:58
  • Introduction to testing with mock objects
    04:56
  • Configuring Projects to Use Mockito
    02:45
  • Creating a project which uses JUnit and Mockito
    04:07
  • Coding a Layered Architecture - Presentation Layer
    03:26
  • Coding a Layered Architecture - Business Layer
    03:32
  • Coding a Layered Architecture - Persistence Layer
    04:11
  • Putting the correct packages in place to respect the layering
    02:44
  • Writing a test for the Login Controller in the presentation layer
    09:48
  • Preview01:01
  • Writing a test for the Authentication Service in the business layer
    03:57
  • Thinking about design decisions when unit testing
    00:38

  • Section Introduction
    00:58
  • Evolving the Domain and Repository Classes
    06:36
  • Ignoring Tests with @ignore
    04:17
  • Implementing a Finder in the Repository
    00:57
  • Implementing Business Logic in the Service
    03:13
  • Configuring Maven to use Java 8
    02:32
  • Evolving the Repository Class
    01:32
  • Adding a Parameter-driven Finder to the Service
    01:34
  • Refactoring to Evolve a New Service
    01:16
  • Generating Test Methods in the IDE and Toggling Between Production and Test Code
    01:26
  • Introducing the JUnit Mockito Runner and @Mock
    01:04
  • Analyzing the Production Code to Determine How to Write the Arrange Section
    03:58
  • Using Mockito's @InjectMocks to Create the System Under Test with it's Dependenc
    01:33
  • Keep Yourself Motivated by Checking the Happy Path Test Output
    02:06
  • Using the JUnit Assertions API to write the Assert Section
    05:17
  • Thinking About the Weaknesses of the JUnit Assertions API
    01:59
  • The Importance of Checking Your Work as you Go!
    02:29
  • Upgrading a JUnit project to use the full Hamcrest version
    03:11
  • Replacing JUnit assertions with Hamcrest assertions and using assertions with co
    02:12
  • Understanding and Reading Hamcrest Test Failures
    02:46
  • Quick thoughts on Hamcrest individual vs collection Assertions
    00:29
  • Don't invoke unneeded production code in your test classes
    01:01
  • Understanding Evaluation of Hamcrest Matchers
    01:17
  • Thinking about why we keep production code to a minimum in tests
    01:19
  • Creating Complex Hamcrest Assertions with allOf and Property Matchers
    04:32

  • Bonus: Taking your Java knowledge further
    00:12

Requirements

  • Have some knowledge of coding in Java to at least a basic level
  • An awareness and excitement to learn all about unit testing with Junit, Mockito and Hamcrest!
  • Have an interest in understanding unit testing from the ground up through theory and practical examples

Description

Do you want to get hands on demonstrations of JUnit and Mockito in action, want a simple no-fluff guide to how unit testing works including getting an understanding of best practices along the way?

Are you struggling to understand unit testing and would like a friendly guide to help you understand it all completely from the ground up?

Maybe you're a junior Java developer who is just starting out and you need a hands-on guide to JUnit and Mockito unit testing to get up and running quickly?

Or you might be an old hand at Java who has been out of practice and needs to level up your unit testing and JUnit and Mockito knowledge ready for a new project?

Then this course is for you!


We cover the following themes:

  • Foundations - this is all the good stuff that's been distilled down through the years - it's best practices and gets you up and running with knowing the stuff the APIs don't tell you

  • Installation and Set Up / Project Creation - we get you creating a project which uses JUnit and introduce you to the project structure and conventions you need to know

  • Writing Tests with JUnit - we cover exactly how to write unit tests with JUnit in this section and get a feel for the API together, covering best practices and how JUnit works along the way

  • Writing mock objects based unit tests with Mockito - we cover a quick start on getting up and running with Mockito to test a simple layered architecture you might find in a webapp (also coding the presentation, business and data layers in preparation to demonstrate this too!) then we demonstrate using Mockito to write tests for it

  • Using the Hamcrest assertions library - we cover how you can do more powerful assertions in your unit tests by harnessing the power of the Hamcrest assertions library that comes shipped with JUnit.

And the following topics:

  • Arrange/Act/Assert

  • Assertions

  • Testing Conventions

  • Good test characteristics

  • Java project structure

  • Creating a JUnit project with Maven

  • Running unit tests in the IDE

  • Test failures

  • JUnit's fail fast mechanism

  • JUnit's annotations

  • Test fixtures

  • Mock objects and their use in unit testing

  • Mockito basics

  • Layered architecture principles

  • Testing a simple layered architecture with Mockito and JUnit

  • Understanding the different types of assertions

  • Using the JUnit Assertions API and Hamcrest

  • Using Hamcrest matchers

  • Composing Hamcrest matchers and creating complex, yet readable assertions

  • Reading Hamcrest test failures

  • Analysing the production code to guide you to writing unit tests

    and much, much more!

This course takes you straight from the beginning and gets you up and running to be fully proficient at writing unit tests using JUnit, Mockito and Hamcrest in quick time. Maybe you've started a new job where they use it to test their applications, or you're learning industry-standard tools to better place you ahead of the competition or you just want to ramp up your unit testing knowledge quickly in a no-fuss guide - then this course is for you!

Ultimately, by unlocking the mechanics of how JUnit and Mockito work in front of your eyes, you should be able to better test your Java projects with the frameworks and have fun doing so!

I look forward to teaching you all about JUnit, Mockito and unit testing inside! ;)

Who this course is for:

  • Developers who want to know how to write unit tests using JUnit, Mockito and Hamcrest
  • Testers who want to better understand testing theory and be able to write their own unit tests out of interest
  • Anyone who is hungry to learn all about the craft of writing better unit tests and understanding this from the ground up!

Featured review

Valentin Despa
Valentin Despa
96 courses
20 reviews
Rating: 5.0 out of 59 months ago
Matt does a great job of explaining how to get started with unit tests. It provides both the theory but also the practical examples needed to understand. He is very responsive in answering questions and that has been very helpful. Thank you!

Instructors

Matt Speake
Java Technologist and Trainer
Matt Speake
  • 4.3 Instructor Rating
  • 195 Reviews
  • 8,140 Students
  • 7 Courses

Do you want to take your Java skills to the next level?

I started JavaEasily in 2018 so I could produce courses focused on teaching Java technology to students all around the world.

Since then I've been busy creating the Java Easily website and publishing courses and articles on different aspects of Java.

Feel free to check out the JavaEasily YouTube channel and follow us on Facebook and Twitter.

Here's to your success with Java! ;)

Java Easily
Learn Java. Easily.
Java Easily
  • 4.2 Instructor Rating
  • 193 Reviews
  • 8,127 Students
  • 5 Courses

JavaEasily helps you become a better Java developer by teaching you the core skills you need to succeed in Java today.

We create courses for beginner and intermediate Java developers to help them deepen their knowledge and accelerate their developer career!

  • Udemy for Business
  • Teach on Udemy
  • Get the app
  • About us
  • Contact us
  • Careers
  • Blog
  • Help and Support
  • Affiliate
  • Terms
  • Privacy policy
  • Cookie settings
  • Sitemap
  • Featured courses
Udemy
© 2021 Udemy, Inc.