Sling Testing ToolsPage edited by Bertrand DelacretazChanges (3)
Full ContentSling provides a number of testing tools that enable the following use cases:
This pages describes those tools, and points to the bundles that implement them. The testing/samples/integration-tests module demonstrates these tools, and is also meant as a sample project to show how to run integration tests for Sling-based applications. The main Sling integration tests at launchpad/integration-tests were created before this testing framework, and do not (as of March 2011) use it. The new testing tools are simpler to use, but the "old" tests (all 400 of them as I write this) fulfill their validation role for testing Sling itself, there's no real need to modify them to use the new tools. Server-side JUnit tests contributed by bundlesThe services provided by the org.apache.sling.junit.core bundle allow bundles to register JUnit tests, which are executed server-side by the JUnitServlet which is registered by default at /system/sling/junit. This bundle is not dependent on Sling, it should work in other OSGi contexts.
To try the JUnitServlet interactively, install the org.apache.sling.testing.samples.sampletests bundle. This bundle contains a number of test classes, which are registered with the org.apache.sling.junit.core services by way of the Sling-Test-Regexp=.*Test bundle header, defined in the bundle's pom.xml. The JUnit core services use this regular _expression_ to select which classes of the test bundle should be executed as JUnit tests. To list the available tests, open http://localhost:8080/system/sling/junit/ . The servlet shows available tests, and allows you to execute them via a POST request. Adding a path allows you to select a specific subset of tests, as in http://localhost:8080/system/sling/junit/org.apache.sling.junit.remote.html - the example integration tests described below use this to selectively execute server-side tests. The JUnitServlet provides various output formats, including in particular JSON, see http://localhost:8080/system/sling/junit/.json for example. Here's an example executing a few tests using curl: Running tests with curl $ curl -X POST http://localhost:8080/system/sling/junit/org.apache.sling.testing.samples.sampletests.JUnit.json [{ "INFO_TYPE": "test", "description": "testPasses(org.apache.sling.testing.samples.sampletests.JUnit3Test)" },{ "INFO_TYPE": "test", "description": "testPasses(org.apache.sling.testing.samples.sampletests.JUnit4Test)" },{ "INFO_TYPE": "test", "description": "testRequiresBefore(org.apache.sling.testing.samples.sampletests.JUnit4Test)" } ]
Change Notification Preferences
View Online
|
View Changes
|
Add Comment
|
- [CONF] Apache Sling Website > Sling Testing Tools confluence
- [CONF] Apache Sling Website > Sling Testing Tools confluence
- [CONF] Apache Sling Website > Sling Testing Tools confluence
- [CONF] Apache Sling Website > Sling Testing Tools confluence
- [CONF] Apache Sling Website > Sling Testing Tools confluence
- [CONF] Apache Sling Website > Sling Testing Tools confluence
- [CONF] Apache Sling Website > Sling Testing Tools confluence
