


Hi,
I am trying to write junit test cases for my osgi services. I tried to follow the below sling testing tool.
http://sling.apache.org/documentation/development/sling-testing-tools.html
But this is not very intuitive.
Here is what I did to set it up .
<dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.junit.core</artifactId> <version>1.0.8</version> </dependency>
Now I tried accessing http://localhost:8080/system/sling/junit/ but this gives 404 error.
Am I missing anything here ?
Views
Replies
Total Likes
Many OSGi services can be successfully [unit] tested outside of the run-time, that is, they are just POJO so you can test them using JUnit and your favourite mocking framework (e.g. EasyMock). If you need dependency injection, that's no problem either. Whilst in-context testing is certainly very important, so I'm not advocating you don't need do that as well, you can get a long way (catch most bugs early following TDD) by eliminating your external dependencies including complex run-time set-up. Once you are happy that all of your unit tests pass locally, by all means deploy to your OSGi run-time and repeat (along with any integration (black-box) tests).
HTHs
Fraser.
Views
Replies
Total Likes
Some basic verifications !
is 'Apache Sling Junit Core' bundle is installed and active ?
is test folder included in your bundle ?
does your testcases configured to RunWith SlingRemoteTestRunner.class ?
Views
Replies
Sign in to like this content
Total Likes
Many OSGi services can be successfully [unit] tested outside of the run-time, that is, they are just POJO so you can test them using JUnit and your favourite mocking framework (e.g. EasyMock). If you need dependency injection, that's no problem either. Whilst in-context testing is certainly very important, so I'm not advocating you don't need do that as well, you can get a long way (catch most bugs early following TDD) by eliminating your external dependencies including complex run-time set-up. Once you are happy that all of your unit tests pass locally, by all means deploy to your OSGi run-time and repeat (along with any integration (black-box) tests).
HTHs
Fraser.
Views
Replies
Total Likes