aem-junit-skill
v1.1.0
Published
AEM JUnit Testing skill for AI assistants - Comprehensive guide for testing Adobe Experience Manager with JUnit
Maintainers
Readme
AEM JUnit Testing Skill
Comprehensive JUnit testing guide for Adobe Experience Manager (AEM) as a Cloud Service. Designed for AI assistants to generate accurate, production-ready test code.
Overview
This skill provides comprehensive documentation and templates for writing JUnit tests in AEM projects using wcm.io AEM Mocks, Apache Sling Mocks, and Adobe Testing Clients.
Features
- 📚 2,200+ lines of documentation
- 🎯 22 testing scenarios covered
- ⚡ 9 CLI commands for quick reference
- ✅ Working example projects with tests
- 🔧 Platform integrations (Claude, Cursor, Copilot, Codex)
Quick Start
Using npx (No Install)
# Show help
npx aem-junit-skill help
# Show full guide
npx aem-junit-skill guide
# Get Maven dependencies
npx aem-junit-skill deps
# Generate test template
npx aem-junit-skill template model
npx aem-junit-skill template service
npx aem-junit-skill template component
npx aem-junit-skill template servletClone & Install
git clone https://github.com/narendragandhi/aem-junit-skill
cd aem-junit-skill
npm install -g
aem-junit-skill helpWhat's Covered
Testing Scenarios
| Scenario | Status | |----------|--------| | Sling Models (basic & advanced) | ✅ | | OSGi Services | ✅ | | Pages & Components | ✅ | | DAM Assets | ✅ | | Servlets | ✅ | | Workflows | ✅ | | Schedulers | ✅ | | Event Handlers | ✅ | | QueryBuilder | ✅ | | Content Fragments | ✅ | | Context-Aware Configs | ✅ | | Users, Groups & ACLs | ✅ |
Advanced Sling Model Annotations
@ValueMapValue@ChildResource@Self@Named@OptionaldefaultValue@OSGiServiceDefaultInjectionStrategy
Documentation Structure
aem-junit-skill/
├── SKILL.md # Main documentation (2,230 lines)
├── QUALITY_METRICS.md # Quality metrics & coverage
├── PROMPT_TESTS.md # Test prompts for AI evaluation
├── bin/
│ └── run.js # CLI tool
├── skills/
│ └── aem-junit/
│ └── SKILL.md # Primary skill file
├── docs/
│ └── references/
│ └── testing-api-reference.md
├── examples/
│ └── aem-test-verified/ # Working Maven project
├── .github/
│ └── workflows/
│ └── ci.yml # GitHub Actions
└── package.jsonDependencies
<properties>
<aem.sdk.api>2025.11.23482.20251120T200914Z-251200</aem.sdk.api>
<aem-mock.version>5.6.4</aem-mock.version>
<junit.version>5.11.0</junit.version>
<mockito.version>5.14.0</mockito.version>
</properties>Installation by Platform
Claude Code
Option 1: Project-level (recommended)
# In your AEM project root
mkdir -p .claude/skills
curl -o .claude/skills/aem-junit.md https://raw.githubusercontent.com/narendragandhi/aem-junit-skill/main/skills/aem-junit/SKILL.mdOption 2: Using npx
npx aem-junit-skill guide > .claude/skills/aem-junit.mdOption 3: Global installation
mkdir -p ~/.claude/skills
curl -o ~/.claude/skills/aem-junit.md https://raw.githubusercontent.com/narendragandhi/aem-junit-skill/main/skills/aem-junit/SKILL.mdCursor AI
Option 1: Copy rules file
curl -o .cursorrules https://raw.githubusercontent.com/narendragandhi/aem-junit-skill/main/.cursorrulesOption 2: Create .cursor/rules directory
mkdir -p .cursor/rules
curl -o .cursor/rules/aem-junit.mdc https://raw.githubusercontent.com/narendragandhi/aem-junit-skill/main/.cursorrulesGitHub Copilot
mkdir -p .github
curl -o .github/copilot-instructions.md https://raw.githubusercontent.com/narendragandhi/aem-junit-skill/main/.github/copilot-instructions.mdOr append to existing instructions:
curl https://raw.githubusercontent.com/narendragandhi/aem-junit-skill/main/.github/copilot-instructions.md >> .github/copilot-instructions.mdGoogle Gemini CLI
curl -o GEMINI.md https://raw.githubusercontent.com/narendragandhi/aem-junit-skill/main/AGENTS.mdWindsurf / Cascade
mkdir -p .windsurf/rules
curl -o .windsurf/rules/aem-junit.md https://raw.githubusercontent.com/narendragandhi/aem-junit-skill/main/skills/aem-junit/SKILL.mdOpenAI Codex / Other Agents
Use the AGENTS.md file which provides a condensed version of the skill:
curl -o AGENTS.md https://raw.githubusercontent.com/narendragandhi/aem-junit-skill/main/AGENTS.mdExample Test
@ExtendWith(AemContextExtension.class)
class ArticleModelTest {
private final AemContext context = new AemContext();
@BeforeEach
void setUp() {
context.load().json("/test-content.json", "/content/mysite");
context.addModelsForClasses(ArticleModel.class);
}
@Test
void testArticleModel() {
Resource resource = context.resourceResolver().getResource("/content/mysite/article");
ModelFactory modelFactory = context.getService(ModelFactory.class);
ArticleModel model = modelFactory.createModel(resource, ArticleModel.class);
assertNotNull(model);
assertEquals("Test Title", model.getTitle());
}
}Testing the Examples
cd examples/aem-test-verified
mvn testExpected output:
Tests run: 20, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESSExample Tests Included
| Test Class | Tests | Patterns Covered |
|------------|-------|------------------|
| HeroComponentTest | 2 | Basic Sling Model |
| HelloServiceTest | 4 | OSGi Service, Mockito |
| NavigationModelTest | 4 | @Self, @ChildResource |
| SiteConfigTest | 4 | Context-Aware Config |
| AssetApprovalProcessTest | 6 | Workflow, WorkItem mocking |
Contributing
See CONTRIBUTING.md for:
- Development setup
- Adding new examples
- Code style guidelines
- Testing procedures
License
Apache License 2.0 - See LICENSE
