Hi Rob,

On Mon, Mar 25, 2013 at 2:42 PM, Robert A. Decker <[email protected]> wrote:
> I'm setting up some sling junit tests. 
> http://sling.apache.org/site/sling-testing-tools.html
>
> But does anyone have advice on how to organize these tests? I know that they 
> have to be installed with
> a bundle, but this means changing the scope of some testing dependencies from 
> test to compile....

I assume you mean JUnit tests that run server-side in a Sling instance.

The way I use them is to create a normal bundle just for these tests
(so having them under src/main in my source code), along with any
scriptable tests included as initial content.

Then, to run the tests, load any required additional bundles to
provide dependencies that the tests require, and the test bundles
themselves, before running the tests via the Sling JUnit servlet. You
could also use an install folder with a specific run mode
(install.testing) for that. This can be automated with simple utility
classes that run before your tests, see The
testing/samples/integration-tests.

The problem with this setup is that you cannot run the tests directly
from your IDE, but I don't think that's possible without IDE
extensions anyway, as the tests have to be shipped to the Sling
instance in a bundle after compiling them anyway. My setup for testing
is to start the Sling instance in debug mode, connect my IDE as the
test debugger, build and install the bundle with Maven and run the
tests by refreshing the JUnit servlet page in my browser.

> ...And related to that then, if I declare a scope in a child pom that is 
> different than the parent pom, the child declaration
> overrides the parent? ...

I think so.

-Bertrand

Reply via email to