Are you looking for a simple guide to learning unit testing? This video course is perfect for you. It includes hands-on exercises and best practices to help you understand JUnit and Mockito unit testing with ease.
JUnit and Mockito Unit Testing for Java Developers
Instructor: Packt - Course Instructors
Included with
Recommended experience
What you'll learn
Analyze production code to identify areas for writing quality unit tests.
Implement JUnit's fail-fast mechanism to improve test efficiency.
Understand and apply Mockito for creating and using mock objects in unit tests.
Create readable assertions by composing Hamcrest matchers.
Skills you'll gain
Details to know
Add to your LinkedIn profile
September 2024
3 assignments
See how employees at top companies are mastering in-demand skills
Earn a career certificate
Add this credential to your LinkedIn profile, resume, or CV
Share it on social media and in your performance review
There are 6 modules in this course
In this module, we will introduce you to the course and its structure. The welcome video provides an overview of what you can expect from the course, setting the stage for your learning journey. Following this, the course structure overview gives a detailed breakdown of each section, ensuring you know how to navigate through the content effectively.
What's included
2 videos1 reading
In this module, we will delve into the foundations of unit testing. We'll start with an overview of what unit testing is and the basic concepts behind it. You will then learn about JUnit, a popular tool for unit testing in Java, and see how to write a simple unit test using JUnit. The section continues with detailed explanations of the structure of unit tests, conventions to follow, and the characteristics of proper unit tests. Finally, we will cover the use of assertions in JUnit to validate test results effectively.
What's included
8 videos
In this module, we will guide you through the process of creating a Java project using JUnit. We'll begin by demonstrating how to set up a project using the Maven Quickstart Archetype. Next, you'll learn about the typical structure of a Java project, with a focus on the differences between production and test source trees. Finally, we will cover the essential conventions for creating unit tests, including proper package organization and naming practices, ensuring that your tests are well-organized and easy to maintain.
What's included
4 videos1 assignment
In this module, we will cover the comprehensive process of writing and running unit tests using JUnit and IntelliJ IDEA. You will learn how to create test methods with the @Test annotation, run these tests within an IDE, and understand the success and failure of tests. We will explore handling exceptions in test failures and the explicit use of Assert.Fail() for validation logic. Additionally, you will be introduced to JUnit's assertions API and the fail-fast test failure mechanism. Finally, we'll delve into best practices like adding descriptive comments to assertions, maintaining DRY principles with @Before, and understanding test fixture instantiation.
What's included
13 videos
In this module, we will explore the use of mock objects and Mockito for unit testing. You'll start by understanding the fundamentals of Mockito and how mock objects are used in testing. We will guide you through configuring projects with Mockito and creating projects that utilize both JUnit and Mockito. The section covers coding and testing various layers of a layered architecture, including the presentation, business, and persistence layers, ensuring proper package organization. Additionally, you'll learn about setting up test fixtures for mock object-based tests and writing specific tests for components like the login controller and authentication service. Finally, we will discuss important design decisions to consider when unit testing your applications.
What's included
13 videos
In this module, we will dive into the Hamcrest Assertions Library and its applications in unit testing. You will begin by evolving domain and repository classes and learning how to ignore tests using the @ignore annotation. We'll cover the implementation of finders in the repository and business logic in the service layer, along with configuring Maven for Java 8. The section includes refactoring practices to develop new services and generating test methods in the IDE. You'll explore JUnit Mockito Runner, @Mock, and @InjectMocks annotations, and learn to analyze production code for effective test writing. We will replace JUnit assertions with Hamcrest assertions, tackle Hamcrest test failures, and create complex assertions using the allOf method and property matchers.
What's included
25 videos2 assignments
Instructor
Offered by
Recommended if you're interested in Software Development
LearnQuest
Coursera Project Network
University of Minnesota
Why people choose Coursera for their career
New to Software Development? Start here.
Open new doors with Coursera Plus
Unlimited access to 7,000+ world-class courses, hands-on projects, and job-ready certificate programs - all included in your subscription
Advance your career with an online degree
Earn a degree from world-class universities - 100% online
Join over 3,400 global companies that choose Coursera for Business
Upskill your employees to excel in the digital economy
Frequently asked questions
Yes, you can preview the first video and view the syllabus before you enroll. You must purchase the course to access content not included in the preview.
If you decide to enroll in the course before the session start date, you will have access to all of the lecture videos and readings for the course. You’ll be able to submit assignments once the session starts.
Once you enroll and your session begins, you will have access to all videos and other resources, including reading items and the course discussion forum. You’ll be able to view and submit practice assessments, and complete required graded assignments to earn a grade and a Course Certificate.