Video description
Do you want to get hands-on demonstrations of JUnit and Mockito in action, in a simple no-fluff guide to how unit testing works?
Are you struggling to understand unit testing and would like a friendly guide to help you get it 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 skills for a new project?
Perhaps you've started a new job where JUnit and Mockito are used to test applications, and you need to get up to speed on the best practices. 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! It takes you straight from the beginning, and gets you up and running, then fully proficient at writing unit tests using JUnit, Mockito and Hamcrest. It unlocks the mechanics of how JUnit and Mockito work, so you are able to better test your Java projects with the frameworks and have fun doing so!
Distributed by Manning Publications
This course was created independently by Matt Speake and is distributed by Manning through our exclusive liveVideo platform.
About the Technology
About the Video
What's Inside
- Write unit tests confidently using JUnit
- Understand mocking and mock objects and how to test interactions with Mockito
- Use Mockito to create test fixtures and stub methods by programmatic and annotation-driven test setup
- Analyze production code to guide writing unit tests
- Learn the JUnit Assertions API
- Write assertions with Hamcrest, the popular assertions library shipped with JUnit
About the Reader
Basic knowledge of coding in Java
About the Author
Matt Speake is a professional Java software engineer and have been programming for more than 20 years, working everywhere from small startups to large investment banks.
He started JavaEasily in 2018 so he could produce courses focused on teaching Java technology to students all around the world.
Since then he has 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 it on Facebook and Twitter.
Quotes
Table of contents
- Introduction
- Unit Testing Foundations
- Creating a Java Project which uses JUnit
-
Writing and Running Unit Tests with JUnit and IntelliJ IDEA
- 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 test 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 workin
- 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?
- Introduction to testing with 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
-
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 Dependencies
- 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 and using assertions with collections
- 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
Product information
- Title: JUnit and Mockito Unit Testing for Java Developers
- Author(s):
- Release date: December 2022
- Publisher(s): Manning Publications
- ISBN: 10000DIVC2022182
You might also like
video
JUnit and Mockito Unit Testing for Java Developers
Are you looking for a simple, no-nonsense guide to learning how unit testing works? This video …
video
Learn Java Unit Testing with JUnit 5 in 20 Steps
JUnit is a unit testing framework for the Java programming language. JUnit has been important in …
video
Mockito Tutorial: Learn mocking with 25 Junit Examples
Writing great unit tests distinguishes good programmers from great programmers. In this course, you will learn …
book
JUnit in Action, Third Edition
JUnit is the gold standard for unit testing Java applications. Filled with powerful new features designed …