Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

AEM Integration Tests with AEM Project Archetype 20

Avatar

Level 1

I have built my new AEM project using the latest AEM Project Archetype 20, and I have some questions about the integration tests; more so, AEM 6.3, AEM 6.4, AEM 6.5.

After building the AEM Project, I see it.launcher and it.test module. As instructions are stated in the parent README.md, running mvn clean verify -PintegrationTests would do the trick successfully; The launchpad will be surfaced; the integration test passes.

While I am trying to insert new code for making tests for my sling model, workflows, osgi services, listeners, etc... it is very difficult for me to debug my tests as I am getting errors in my intelliJ. There is no documentation at all for me to understand how to get started with the out of the box it.launcher and it.test module setup. Reviewing the sample it.test setup, the code is very confusing. The context HelloWorldModelServerSideTest.java makes no sense where all of a sudden we are creating a new object "AdminResolverCallable" within the tests. Searching on Google, "AdminResolverCallable" does not exist at all. Where are the documentation that explains which helper classes/framework we can utilize?

As I try to debug my code (using intelliJ debugging tools), I am consistently getting errors like SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" and java.lang.NoClassDefFoundError: org/osgi/framework/BundleActivator; including breakpoints is definitely not working for me. I feel like adding custom code changes to the it.test module is daunting, hard to understand, and have no documentation for us developers to understand how to get started with integration tests on AEM.

[concerning] While looking at the latest AEM core components (https://github.com/adobe/aem-core-wcm-components), even that project itself has no examples of how integration tests are run; maybe it's so difficult to set up that they just removed it.

Trying to work with it.launcher and it.test module is so difficult, here is my question. Can we use https://wcm.io/ to write integration tests? Unit tests are working well with the WCM.IO framework already.

The WCM.IO framework includes:

  • Access to mocked OSGi, mocked JCR and mocked Sling environment provided by the Apache Sling project
  • Resource access using different resource resolver types (see Resource Resolver Types)
  • Implementation of AEM WCM API objects PageManager, Page, Template, ComponentManager, Component, TagManager, Tag, Designer, ComponentContext, EditContext, EditConfig, Style, ContentPolicy, ContentPolicyMapping, ContentPolicyManager
  • Implementation of AEM DAM API objects Asset, Rendition, ContentFragment, AssetStore, AssetHandler.
  • Implementation of AEM Granite API objects ResourceCollectionManager, ResourceCollection
  • JUnit rule AemContext for easy access to all context objects and registering adapter factories and OSGi services
  • Import and create test content for unit tests (see Test content loading and creation)
  • Registers OSGi services and adapter factories supported by the mock implementations
  • Full support for Sling Models
  • Setting run modes
  • Layer adapter factory
  • Context Plugins

Missing models injector can be used from ACS common's Sling Models Injector -> AEM Objects Sling Models Injector

If this is not the best practice, can we please have better documentation for the integration sample piece for the AEM Archetype project? The internet has no information on how to properly run inteegration tests for AEM.

Please.

0 Replies