You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stanbol.apache.org by Ali Anil Sinaci <a....@gmail.com> on 2012/03/19 16:10:01 UTC

Sling test tools for Contenthub

Hi all,

As far as I understand, to use sling test annotations and execute junit 
tests with SlingAnnotationsTestRunner, someone should send an HTTP POST 
request to the associated endpoint 
(/system/sling/junit/o.a.s.contenthub.test.X). I am planning to send 
these requests within the integration-tests. But, this leads to 
"executing unit tests within integration-tests".

Do you have any experience/suggestion on this?

Best,
Anil.

Re: Sling test tools for Contenthub

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

On Tue, Mar 20, 2012 at 8:25 AM, Ali Anil Sinaci <a....@gmail.com> wrote:
> ...Let me describe myself. I have a number of unit test classes in which there
> are "org.apache.sling.junit.annotations.TestReference" annotations. These
> classes has @RunWith(SlingAnnotationsTestRunner.class) annotations also. I
> want to execute these tests within the maven process during a complete build
> of Stanbol...

Ok, so that does match the examples at [1],

> ...Is "sending HTTP requests to these classes" the only way to execute these
> unit tests?..

HTTP requests are actually sent to the JUnit servlet that runs
server-side, providing a proxy mechanism to execute tests.

> ...If so, does sending these requests within the integration-tests
> violates any pattern?...

I don't think so - purists might complain that these are integration
tests and not unit tests, but do we care? ;-)

If you can run your tests purely from the HTTP interfaces of your
components I think that's better, as it's a more direct method, easier
to understand, and it's also helpful in documenting those HTTP
interfaces.

OTOH, if you tests need the full OSGi framework, running them via this
proxy mechanism makes a lot of sense to me - they run in the actual
environment where they will be used, so you can be reasonably sure
that you're testing something meaningful.

-Bertrand

[1] [1]  http://svn.apache.org/repos/asf/sling/trunk/testing/samples/integration-tests

Re: Sling test tools for Contenthub

Posted by Ali Anil Sinaci <a....@gmail.com>.
Hi Bertrand,

Let me describe myself. I have a number of unit test classes in which 
there are "org.apache.sling.junit.annotations.TestReference" 
annotations. These classes has 
@RunWith(SlingAnnotationsTestRunner.class) annotations also. I want to 
execute these tests within the maven process during a complete build of 
Stanbol.

Is "sending HTTP requests to these classes" the only way to execute 
these unit tests? If so, does sending these requests within the 
integration-tests violates any pattern?

Thanks in advance,
Anil.

On 03/19/2012 05:34 PM, Bertrand Delacretaz wrote:
> Hi Anil,
>
> On Mon, Mar 19, 2012 at 4:10 PM, Ali Anil Sinaci<a....@gmail.com>  wrote:
>> ...As far as I understand, to use sling test annotations and execute junit
>> tests with SlingAnnotationsTestRunner, someone should send an HTTP POST
>> request to the associated endpoint
>> (/system/sling/junit/o.a.s.contenthub.test.X). I am planning to send these
>> requests within the integration-tests. But, this leads to "executing unit
>> tests within integration-tests"....
> So IIUC you want to run JUnit tests inside a running Stanbol instance,
> from the outside?
>
> That's what the examples at [1] do, if you look at the
> ServerSideSampleTest in there for example, it runs in the test phase
> of a Maven build, triggers server-side tests using an HTTP request as
> you describe, and reports the result as part of the Maven build
> output.
>
> Is that what you want?
>
> -Bertrand
>
> [1]  http://svn.apache.org/repos/asf/sling/trunk/testing/samples/integration-tests


Re: Sling test tools for Contenthub

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

On Mon, Mar 19, 2012 at 4:10 PM, Ali Anil Sinaci <a....@gmail.com> wrote:
> ...As far as I understand, to use sling test annotations and execute junit
> tests with SlingAnnotationsTestRunner, someone should send an HTTP POST
> request to the associated endpoint
> (/system/sling/junit/o.a.s.contenthub.test.X). I am planning to send these
> requests within the integration-tests. But, this leads to "executing unit
> tests within integration-tests"....

So IIUC you want to run JUnit tests inside a running Stanbol instance,
from the outside?

That's what the examples at [1] do, if you look at the
ServerSideSampleTest in there for example, it runs in the test phase
of a Maven build, triggers server-side tests using an HTTP request as
you describe, and reports the result as part of the Maven build
output.

Is that what you want?

-Bertrand

[1]  http://svn.apache.org/repos/asf/sling/trunk/testing/samples/integration-tests