Expand my Community achievements bar.

JUnit 4: AEM Sling Models Unit Test Constructor Injection Example | AEM Community Blog Seeding

Avatar

Administrator

BlogImage.jpg

JUnit 4: AEM Sling Models Unit Test Constructor Injection Example by sourcedcode

Abstract

In this example, we will take a look at how we can mock Sling Model Constructor Injection dependencies for a JUnit 4 Unit test.

Scenario:
The Sling Model must expose either the PROD_URL or the DEAFULT_URL endpoint based on the run mode or request parameters; this is the requirement. The example below will demonstrate the implementation of logic utilising Sling Model Constructor injection, show Unit test examples, and how mocked dependencies can be Sling Model Constructor injected during the test phase. This completes the example.

Read Full Blog

JUnit 4: AEM Sling Models Unit Test Constructor Injection Example

Q&A

Please use this thread to ask the related questions.



Kautuk Sahni
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies