Highlighted

How do I use TeleporterRule's withRources method?

Avatar

Avatar

Elkish

Avatar

Elkish

Elkish

01-04-2019

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?

Replies

Highlighted

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K
smacdonald2008

01-04-2019

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.

Highlighted

Avatar

Avatar

Elkish

Avatar

Elkish

Elkish

01-04-2019

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.