Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One approach is to use a Sling test runner to execute the JUnit tests via a browser. This is the approach you are mentioning. We had to first install the code in this JAR (<a href="http://search.maven.org/#search%7Cga%7C1%7Corg.apache.sling.junit.core" rel="nofollow">org.apache.sling.junit.core</a>) to add the code that allows the URL you listed to work. Once that code is there, this URL will allow you to run tests using the test runner's built in page to run/display tests: <code>http://localhost:4502/system/sling/junit/</code>). My team did this for a while, but we soon moved to a different approach--using the Intellij IDE to develop the Java code for CQ and write the JUnit tests, then executing them within the IDE using the built-in JUnit test runner. The same approach works in Eclipse. For our team this approach was superior because it allowed developers to remain in context in the IDE without having to switch to a browser to run the tests.</p> <p>The key is being able to resolve the references to classes that are installed/available via CQ, such as the SlingRepository and ResourceResolverFactory classes--and other stuff we commonly used, such as the Resource, ResourceResolver, Node, and Session classes. We use a CQ extension (<a href="http://helpx.adobe.com/experience-manager/kb/HowToUseCQ5AsMavenRepository.html" rel="nofollow">http://helpx.adobe.com/experience-manager/kb/HowToUseCQ5AsMavenRepository.html</a>) to allow our CQ instance to act like a Maven repository. This allows us to export the CQ JARs so we can then reference them as dependencies in the Java projects we create whenever we may need to use some of the classes available via CQ itself.</p> <p>Once we set up the project dependencies, then we were able to write code--and corresponding unit tests--within the Intellij IDE. We were able to run the tests within the IDE, allowing developers to remain in context and work on the code that will run in CQ just like they work on any Java code (including things like running tests in debug mode or with code coverage, running single tests, running all tests in a class, using keyboard shortcuts to kick off tests, etc.). For us this approach had many advantages over the browser-based Sling test runner, so I recommend this approach.</p> <p>Some potential considerations:</p> <ul> <li>Exporting from CQ as a Maven repo may not be the best performance--you may want to add things to your own Maven repo for faster access</li> <li>You may want to script some of the steps so adding project dependencies is not a manual process, but rather is something done via an automated process</li> <li>You could even export <em>all</em> CQ JARs--or add some scripting to parse out and repackage only the public classes--and make any CQ class available to your Java projects</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload