You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by "Robert A. Decker" <de...@robdecker.com> on 2013/03/25 14:42:06 UTC

sling testing and dependency scope

Hi,

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'm assuming now that I should stick these in a separate bundle so that I can separate out the test code when I want to deploy something for production. Is this what people generally do, separate these runtime tests into a separate bundle?

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 would like to continue having some tests run at compile time with scope test, and have these new tests run in the runtime environment.

Rob

Re: sling testing and dependency scope

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Rob,

On Thu, Mar 28, 2013 at 9:56 AM, Robert A. Decker <de...@robdecker.com> wrote:
> ...I got it working. It's great. At some point we'll try to find some way to automate it further as part of the build process, but for now it's fine....

Cool - as usual contributions are welcome if you find better/more
integrated ways of running these tests. One thing that's on my mind is
to be able to find out which integration tests need to run based on
which combinations of bundles are installed in the instance under
test.

-Bertrand

Re: sling testing and dependency scope

Posted by "Robert A. Decker" <de...@robdecker.com>.
Hi,

I got it working. It's great. At some point we'll try to find some way to automate it further as part of the build process, but for now it's fine.

Rob

On Mar 25, 2013, at 5:27 PM, Bertrand Delacretaz wrote:

> Hi Rob,
> 
> On Mon, Mar 25, 2013 at 2:42 PM, Robert A. Decker <de...@robdecker.com> 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
> 


Re: sling testing and dependency scope

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Rob,

On Mon, Mar 25, 2013 at 2:42 PM, Robert A. Decker <de...@robdecker.com> 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