Constructor must call super() or this() Junit | Community
Skip to main content
Level 5
June 14, 2017

Constructor must call super() or this() Junit

  • June 14, 2017
  • 2 replies
  • 3599 views

Hi,

I am trying to execute simple test case, but getting an error. Below is my test case :

@Rule
public AemContext context = new AemContext();

@Test
public void test() throws Exception {

   Resource currentResource = context.create().resource("/content/app/en-us/page",

   "jcr:title", "Title Page", "width", "5","height","9");

   inheritanceValueMap = Mockito.spy(new HierarchyNodeInheritanceValueMap(currentResource));

  Assert.assertThat(inheritanceValueMap.getInherited("width", StringUtils.EMPTY), Is.is("5"));

}

Error I am getting is :

java.lang.VerifyError: (class: com/day/cq/commons/ValueMapWrapper, method: <init> signature: (Lorg/apache/sling/api/resource/ValueMap;)V) Constructor must call super() or this()

Any solution to this?

Thanks,

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

smacdonald2008
Level 10
June 14, 2017

Take a look at this community blog on this subject: Adobe CQ/Adobe AEM: How to Write Tests in AEM

Also - I recommend that you watch this GEMS session: From Unit Testing to Integration Test of an AEM Application

Level 2
June 15, 2017

Hi,

This issue usually comes when we use below dependency of uber jar :

<dependency>

   <groupId>com.adobe.aem</groupId>

   <artifactId>uber-jar</artifactId>

   <version>6.2.0</version>

   <classifier>obfuscated-apis</classifier>

   <scope>provided</scope>

</dependency>

Try changing the dependency classifier to apis , as shown below:

<dependency>

   <groupId>com.adobe.aem</groupId>

   <artifactId>uber-jar</artifactId>

   <version>6.2.0</version>

   <classifier>apis</classifier>

   <scope>provided</scope>

</dependency>