Learn how to use @DataJpaTest to test our JPA repository in JUnit.
Search Results for: junit
Injecting @Mock and @Captor in JUnit 5 Method Parameters
Learn how to inject the @Mock and @Captor annotations in unit test method parameters.
Solving the ParameterResolutionException in JUnit 5
Learn how to solve the ParameterResolutionException in JUnit 5.
Asserting Nested Map With JUnit
Learn the different ways of asserting the presence of a nested map with JUnit.
Assert Regex Matches in JUnit
Explore several approaches to asserting regex matches in JUnit, empowering us to test our string patterns effectively.
Test Main Method with JUnit
Learn how to test the main method in Java with Junit.
Fail Maven Build if JUnit Coverage Falls Below Certain Threshold
Learn how to cause a Maven build to fail when the JaCoCo code coverage falls below a given threshold.
Unit Testing of System.in With JUnit
Learn how to test user input scenarios using System.in with JUnit 4 and JUnit 5.
Creating a Test Suite With JUnit
Learn two different ways for creating test suites with JUnit.
Execute Tests Based on Active Profile With JUnit 5
Learn how to execute tests based on the active Spring profile using JUnit 5.
A Guide to @Timeout Annotation in JUnit 5
Explore JUnit5’s new @Timeout annotation.
The Difference Between junit-vintage-engine and junit-jupiter-engine
Explore the difference between the junit-vintage-engine and the junit-jupiter-engine.
JUnit 5 @Nested Test Classes
Learn about JUnit 5’s @Nested annotation.
SpringRunner vs MockitoJUnitRunner
Learn the key differences between SpringRunner and MockitoJUnitRunner and understand their purpose.
JUnit – Testing Methods That Call System.exit()
Learn techniques for testing methods that call System.exit() when using JUnit.
assertAll() vs Multiple Assertions in JUnit5
Normally a single assertion failure will stop a unit test. However, we can group assertions together, and report on their combined success or failure, using assertAll() within JUnit 5.
Why Maven Doesn’t Find JUnit Tests to Run
A practical guide to solving Maven test running issues.
Get the Name of the Currently Executing Test in JUnit
Sometimes we need our unit tests to be able to access the name JUnit has allocated to them. This is especially useful when using name generators or parameterized tests. We look at how to solve this problem in both JUnit 4 and 5.
Failed to Load ApplicationContext for JUnit Test of Spring Controller
Learn about the “Failed to Load ApplicationContext” error message when running Junit tests with the Spring Controller, and how to fix it.
Parallel Test Execution for JUnit 5
In this article, we’ll cover how to execute parallel unit tests using JUnit 5.