JUNIT 5: ArgumentCaptor with Mockito
Unit testing isn’t just about confirming your code works; it’s about ensuring it excels. Mockito, a trusted mock framework, introduces the ArgumentCaptor, a potent tool for honing your unit tests. This feature empowers you to capture and assert method arguments, leading to highly targeted tests. In this article, we’ll delve into the realm of ArgumentCaptor […]
JUNIT 5: JCR SQL 2 Unit Tests w/ Sling Servlet
I’ve dedicated quite a chunk of my personal time to crafting this blog post, and yes, I’ve rigorousl… This page is premium content. By supporting this website, please subscribe. Subscribe now for $1 for 1 month of premium content. Username or E-mail Password Remember Me Forgot Password
JUNIT5: What Exactly is org.mockito.junit.jupiter.MockitoExtension and Sling Model Example
org.mockito.junit.jupiter.MockitoExtension is a JUnit 5 extension provided by the Mockito library. It allows you to use the Mockito framework to create and inject mocked objects into your JUnit 5 test classes. This extension provides several features such as annotation-based mock creation, automatic detection of unused stubs, and support for the Mockito API. It enables you […]
AEM JUNIT5 with io.wcm.testing.mock.aem.junit5.AemContextExtension
io.wcm.testing.mock.aem.junit5.AemContextExtension is an extension for JUnit 5 that provides a way to run AEM (Adobe Experience Manager) unit tests with mocked AEM objects. This extension allows you to set up an AemContext object in your JUnit 5 test class, which provides access to mocked AEM objects such as the ResourceResolver, SlingSettings, and more. This makes […]
Mocking Static Methods in JUNIT5
PowerMock is a Java framework that allows you to unit test code that uses static methods, constructors, and private methods. PowerMock uses a combination of bytecode manipulation and reflection to enable the mocking of these types of methods. PowerMock is not officially supported by JUnit 5. PowerMock is built on top of EasyMock and provides […]
JUnit 5: Mocking the HttpClient in Java
Unfortunately when building AEM backend logic, the org.apache.http.client.HttpClient is non-trivial to write unit tests. In my case, I scavenged across the net to find a solution where you can make an GET and POST request via HttpClient in particular for AEM, and unit test is performing as expected. In order for me write successful to […]