0

I'm trying to execute a JUnit test remotely on an Adobe AEM instance, using the JUnit Servlet. Post for reference: Which Testing framework will suit for Adobe CQ5 Project?

I've defined my testcase and was expecting to be able to see it at this URL

http://localhost:4502/system/sling/junit/

It does not show up though.

The test runs correctly with mvn test.

it's a very simple test case (junit3):

import junit.framework.TestCase;
 public class mySampleTest extends TestCase {
    public void testSomething(){
        return;
    }
}

What do I need to do in order for the testcase to be available in the Sling remote JUnit test servlet?

Community
  • 1
  • 1
mish
  • 1,055
  • 10
  • 29
  • I got a little bit further, I've noticed I had to add the Sling-Test-Regexp tag to my pom. `.*` Now it shows all the classes but not those that contain the tests. – mish Mar 02 '15 at 09:09
  • Ok, it was indeed that. I set the Sling-Test-Regexp to .*Test and it shows only the classes ending with "Test" (as expected). Now I have to figure out why the classes in /src/main/test/ are ignored. – mish Mar 02 '15 at 11:02

1 Answers1

1

I think you need to add annotation @RunWith(SlingRemoteTestRunner.class). Also you should read about it here and you can see example here

Oleksandr Tarasenko
  • 1,454
  • 15
  • 21
  • Thanks for answering, the resources you've provided are known to me. AFAIK the RunWith Annotation is not neccessary - for example I'm able to run this test supplied by the sling integration tests: http://grepcode.com/file_/repo1.maven.org/maven2/org.apache.sling/org.apache.sling.junit.remote/1.0.8/org/apache/sling/junit/remote/exported/ExampleRemoteTest.java/?v=source – mish Mar 02 '15 at 07:47
  • yes, this is another way of creating remote tests. But what about creating execution rule - SlingRemoteExecutionRule? – Oleksandr Tarasenko Mar 02 '15 at 12:27
  • What about it? Could you elaborate? – mish Mar 02 '15 at 12:55
  • Ok, I looked into example you posted and I found that tests in "org.apache.sling.testing.samples.sampletests" bundle are located under src/main and not under test/java what is logical, because test/java is not included into the bundle. So you can move your test into src/main and it will appear on sling junit servlet. – Oleksandr Tarasenko Mar 02 '15 at 16:04
  • I've found that out :) My workaround was to configure the maven build in a way to put the compiled test class files in the same location as the others. – mish Mar 02 '15 at 16:21