Highlighted

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

Avatar

Avatar

kautuk_sahni

Community Manager

Total Posts

5.6K

Likes

959

Correct Answer

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

5.6K

Likes

959

Correct Answer

1.1K
kautuk_sahni
Community Manager

05-07-2020

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.

AEM AEMEBlogSeeding Experience Manager