Adding a better and cleaner solution for those who are having this
issue. wcm.io provides libraries and extension for AEM applications. We
can use the same to create AemContext. They have recently addresses this
issue and added straightforward solution (issue link), details here. We
can import
com.adobe.cq.wcm.core.components.testing.mock.ContextPlugins.CORE_COMPONENTS
and use them as a parameter to .plugin(). So our AemContext
initialization would look like this. private final AemContext ctx = ...