Integration testing with WCM IO - AemContext
Hi all,
I am trying to write Junit test by using WCM IO testing tools. I have been reading lots of articles but I can't make it work. The steps I follow are:
- Add maven dependency for AEM 6.2
<dependency> <groupId>io.wcm</groupId> <artifactId>io.wcm.testing.aem-mock</artifactId> <version>2.2.0</version> </dependency>
Add test case within the core bundle
package com.my.project.core.models; import org.apache.sling.api.resource.ResourceResolver; import org.junit.Rule; import org.junit.Test; import io.wcm.testing.mock.aem.junit.AemContext; public class MyFirstITest { @Rule public final AemContext context = new AemContext(); @Test public void itWorksTest() throws Exception { ResourceResolver rr = context.resourceResolver(); // Test someting } }- Run the test --> ERROR: java.lang.NoClassDefFoundError: org/junit/rules/TestRule.... Caused by: java.lang.ClassNotFoundException: org.junit.rules.TestRulea
- Building with maven --> ERROR: COMPILATION ERROR : ... MyFirstITest.java:[16,47] cannot access org.junit.rules.TestRule .... class file for org.junit.rules.TestRule not found
Does anybody use this library to write unit tests? Does anybody make it work? I have been following: http://wcm.io/testing/aem-mock/usage.html#Sling_Models
Cheers,
Salva.
