Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

How do I use TeleporterRule's withRources method?

Elkish
Level 2
Level 2

Our team is setting up some tests for our AEM code using the TeleporterRule documented at "Apache Sling :: JUnit server-side testing support bundles".  Our goal currently is to make it easy to set up a test that is able to set the JCR up with specific data, which allows us to make in-depth assertions about service output.  We've managed to get tests mostly up and running, but are having trouble sorting out the withResources method.  Based on my read of the docs, withResources appears to be intended to provide a mechanism for populating the JCR with data prior to tests being run.

Assuming I construct my test rule like so:

@Rule

public final TeleporterRule teleporter = TeleporterRule.forClass(getClass()).withResources("/test/");

1. Where in the package will the TeleporterRule look when it attempts to load resources from "/test/"?
2. Is there any additional setup needed to get this to work, i.e. adding a filter rule to the package?

3. Does the TeleporterRule automatically clean up any resources that were created in the withResources step?

2 Replies
smacdonald2008
Level 10
Level 10

We ran a webinar last month on testing AEM content that you may find useful. See:

March 2019 Version of Ask the AEM Community Experts - YouTube

Hope this helps...

PS - there are links too that contains more useful information.

Elkish
Level 2
Level 2

Thanks for the quick reply, and while this is a great tutorial for doing unit testing it specifically mentions that it isn't designed to help with integration testing.  Our service code leverages the caravan library to bind service output to JAX-RS style endpoints, and we really want to perform integration tests to insure the services work properly each time new code is merged.  There are a number of tools for doing this, but Sling's TeleporterRule seemed like the most promising as it allows you to effectively write your integration tests in the same way we write our unit tests.