Zenler Player
Your course is loading. Hang tight.
JUnit and Mockito Unit Testing for Java Developers
Back to curriculum
0% Complete
0% Complete
Welcome to the Course!
Overview of the Course Structure
Section Introduction
What is Unit Testing?
What is JUnit?
Introducing a Simple Unit Test in JUnit
Structure of a Unit Test (Arrange-Act-Assert and Given/When/Then)
Conventions for Writing Unit Tests
Characteristics of Proper Unit Tests
What are Assertions?
Section Introduction
Creating a Java project which includes JUnit using the Maven Quickstart Archetype
Introducing a typical Java project structure (production vs test source trees)
Understanding the basic conventions for creating unit tests (package and naming)
Section Introduction
Creating a test method with the @Test annotation
Running a unit test within the IDE and understanding test success
Understanding test failures with exceptions
Failing a unit tests explicitly with Assert.fail
Using Assert.fail to check validation logic in a try/catch
An introduction to the JUnit Assertions API
Structuring unit tests with Arrange/Act/Assert
Understanding execution of assertions and JUnit's fail-fast test failure mechanism
Adding descriptive comments to assertions and test failures to aid diagnostics
Coding a unit test following Arrange-Act-Assert
Keeping test setup DRY with @Before
Understanding test fixture instantiation
Section introduction
What is Mockito and what are mock objects?
Configuring Projects to Use Mockito
Creating a project which uses JUnit and Mockito
Coding a Layered Architecture - Presentation Layer
Coding a Layered Architecture - Business Layer
Coding a Layered Architecture - Persistence Layer
Putting the correct packages in place to respect the layering
Writing a test for the Login Controller in the presentation layer
Understanding the test fixture setup when writing mock object based unit tests
Writing a test for the Authentication Service in the business layer
Thinking about design decisions when unit testing
Section Introduction
Evolving the Domain and Repository Classes
Ignoring Tests with @ignore
Implementing a Finder in the Repository
Implementing Business Logic in the Service
Configuring Maven to use Java 8
Evolving the Repository Class
Adding a Parameter-driven Finder to the Service
Refactoring to Evolve a New Service
Generating Test Methods in the IDE and Toggling Between Production and Test Code
Introducing the JUnit Mockito Runner and @Mock
Analyzing the Production Code to Determine How to Write the Arrange Section
Using Mockito's @InjectMocks to Create the System Under Test with it's Dependenc
Keep Yourself Motivated by Checking the Happy Path Test Output
Using the JUnit Assertions API to write the Assert Section
Thinking About the Weaknesses of the JUnit Assertions API
The Importance of Checking Your Work as you Go!
Upgrading a JUnit project to use the full Hamcrest version
Replacing JUnit assertions with Hamcrest assertions and using assertions with co
Understanding and Reading Hamcrest Test Failures
Quick thoughts on Hamcrest individual vs collection Assertions
Don't invoke unneeded production code in your test classes
Understanding Evaluation of Hamcrest Matchers
Thinking about why we keep production code to a minimum in tests
Creating Complex Hamcrest Assertions with allOf and Property Matchers
Introduction
Welcome to the Course!
Preview
Overview of the Course Structure
Preview
Unit Testing Foundations
Section Introduction
What is Unit Testing?
What is JUnit?
Introducing a Simple Unit Test in JUnit
Preview
Structure of a Unit Test (Arrange-Act-Assert and Given/When/Then)
Preview
Conventions for Writing Unit Tests
Characteristics of Proper Unit Tests
What are Assertions?
Creating a Java Project which uses JUnit
Section Introduction
Creating a Java project which includes JUnit using the Maven Quickstart Archetype
Preview
Introducing a typical Java project structure (production vs test source trees)
Understanding the basic conventions for creating unit tests (package and naming)
Writing and Running Unit Tests with JUnit and IntelliJ IDEA
Section Introduction
Creating a test method with the @Test annotation
Preview
Running a unit test within the IDE and understanding test success
Understanding test failures with exceptions
Failing a unit tests explicitly with Assert.fail
Using Assert.fail to check validation logic in a try/catch
An introduction to the JUnit Assertions API
Structuring unit tests with Arrange/Act/Assert
Understanding execution of assertions and JUnit's fail-fast test failure mechanism
Adding descriptive comments to assertions and test failures to aid diagnostics
Coding a unit test following Arrange-Act-Assert
Keeping test setup DRY with @Before
Understanding test fixture instantiation
Unit Testing with Mock Objects and Mockito
Section introduction
What is Mockito and what are mock objects?
Preview
Configuring Projects to Use Mockito
Creating a project which uses JUnit and Mockito
Coding a Layered Architecture - Presentation Layer
Coding a Layered Architecture - Business Layer
Coding a Layered Architecture - Persistence Layer
Putting the correct packages in place to respect the layering
Writing a test for the Login Controller in the presentation layer
Understanding the test fixture setup when writing mock object based unit tests
Preview
Writing a test for the Authentication Service in the business layer
Thinking about design decisions when unit testing
Looking at the Hamcrest Assertions Library
Section Introduction
Evolving the Domain and Repository Classes
Ignoring Tests with @ignore
Implementing a Finder in the Repository
Implementing Business Logic in the Service
Configuring Maven to use Java 8
Evolving the Repository Class
Adding a Parameter-driven Finder to the Service
Refactoring to Evolve a New Service
Generating Test Methods in the IDE and Toggling Between Production and Test Code
Introducing the JUnit Mockito Runner and @Mock
Analyzing the Production Code to Determine How to Write the Arrange Section
Using Mockito's @InjectMocks to Create the System Under Test with it's Dependenc
Keep Yourself Motivated by Checking the Happy Path Test Output
Using the JUnit Assertions API to write the Assert Section
Thinking About the Weaknesses of the JUnit Assertions API
The Importance of Checking Your Work as you Go!
Upgrading a JUnit project to use the full Hamcrest version
Replacing JUnit assertions with Hamcrest assertions and using assertions with co
Understanding and Reading Hamcrest Test Failures
Quick thoughts on Hamcrest individual vs collection Assertions
Don't invoke unneeded production code in your test classes
Understanding Evaluation of Hamcrest Matchers
Thinking about why we keep production code to a minimum in tests
Creating Complex Hamcrest Assertions with allOf and Property Matchers
×
This is an unpublished lesson. This lesson will not be shown for students unless you set it as Public.
Back to Dashboard
No contents are available in this lesson!
No lessons available !
Back to Dashboard
Lesson contents locked
Enroll to unlock this lesson.
Enroll to unlock
Next Lesson