Build a small content fixture

For a teaser model, create only the content properties needed to calculate its title and link. Adapt the relevant resource or request to the model and assert those outputs. A large exported content tree can hide the missing property or inheritance rule that the check was supposed to make clear to maintainers.

Choose the mock resource resolver type for the APIs your code uses. AEM Mocks documents differences between resolver options, so do not assume every JCR behavior exists in every setup. Match test dependencies to the application's supported AEM and Java environment before copying example coordinates or annotations from another project.

Register dependencies and check adaptation

Register the model classes, services, or adapter factories needed for the selected behavior. If adaptation returns null, inspect the required injections and adaptable type before adding broad mocks. A test that silently replaces the model's important dependency can miss the configuration error that would prevent the real model from being created.

Use the documented JUnit extension and a nonstatic AemContext field for straightforward per-test isolation. Shared static contexts require special care because content and service changes can remain visible between tests. Keep setup explicit so one case cannot accidentally supply a registered service that another case forgot to provide for itself.

Separate mocked behavior from platform evidence

Test missing properties, invalid configuration, and defined fallback behavior through small synthetic resources. Assert exact model outputs rather than only checking that adaptation succeeded. This gives useful evidence about component logic while keeping the fixture understandable when a future content schema change requires the expected behavior to be reviewed and updated.

Add integration checks for queries, permissions, workflow, or repository semantics that the mock environment cannot establish. A passing AEM Mocks test does not prove deployment configuration or real-instance behavior. Document the excluded boundary in the coverage map so the team can place additional evidence where platform-specific failure modes actually occur.

Working sheet

AEM test setup decisions
NeedMock setupEvidence limit
Model property mappingMinimal content resourceNo deployment proof
Injected serviceRegistered controlled serviceNo real service integration
Request adaptationConfigured mock requestChosen mock behavior
Repository query semanticsReal integration environmentBeyond simple content fixture
Download this worksheet (CSV)

Questions about test AEM models and services with AEM Mocks

Why does model adaptation return null?

Check registered model classes, adaptable type, required injections, and the content or request setup.

Can AEM Mocks replace every AEM integration test?

No. Use real-instance checks for platform behavior outside the chosen mock implementation.

How should I use the working sheet?

Download the CSV and replace the sample rows with evidence from your repository. Record a clear acceptance check and an owner for each item. Keep unresolved assumptions visible rather than treating the example as a completed assessment.

Sources and further reading

Examples are illustrative. They are not customer results, security guarantees, or a substitute for checking the documentation for your installed version.

Make the next change verifiable.

Getzilla is an open source workflow for changes to existing repositories. Inspect the project, define acceptance checks, and keep independent review in the loop.

See the repository workflow See current access and pricing