JUnit 4: AEM Sling Models Unit Test Constructor Injection Example | AEM Community Blog Seeding | Community
Skip to main content
kautuk_sahni
Community Manager
Community Manager
July 6, 2020

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

  • July 6, 2020
  • 0 replies
  • 1044 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.