I've been working on a prototype JUnit extension framework  that allows JUnit tests to be injected in a Sling instance, and executed via a test runner servlet.
Tests are not yet OSGi-aware in the first prototype, but they are dynamically injected as exported classes in a bundle that points to them with a Test-Package header. Apart from that they are 100% normal JUnit3 or 4 tests.
Next step is to use annotations to inject services in the tests, I'm thinking of something like
public void someTest()...
which would ignore the test if the repository service is not present.
The prototype consists of two bundles: "extension" which is the test detection and runner services, and "testbundle" which provides a few example tests. To play with it, install the two bundles and access the test servlet at /system/sling/junit/
|Labels||integration-tests junit testing|
|Status||Open [ 1 ]||Resolved [ 5 ]|
|Resolution||Fixed [ 1 ]|
|Workflow||no-reopen-closed,doc-test-required [ 12544134 ]||Copy of no-reopen-closed,doc-test-required [ 12764709 ]|
|Workflow||Copy of no-reopen-closed,doc-test-required [ 12764709 ]||no-reopen-closed,doc-test-required [ 12766270 ]|
|Workflow||no-reopen-closed,doc-test-required [ 12766270 ]||re-open possible,doc-test-required [ 12788341 ]|
|Workflow||re-open possible,doc-test-required [ 12788341 ]||no-reopen-closed,doc-test-required [ 12791085 ]|
|Transition||Time In Source Status||Execution Times||Last Executer||Last Execution Date|
|30d 21h 44m||1||Bertrand Delacretaz||03/Mar/11 15:06|