Open jyotsnapa opened 6 years ago
I am having the same problem. The getters inside abstract class are somehow not detected and that results not in full code coverage.
@zygimantus Have you tried to test the abstract class itself?
@jyotsnapa Can you please send an example demonstrating the issue? Also do you have ASM in your dependancies?
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>5.2</version>
</dependency>
It worked! Just curious - why is it required to specify this ASM separately rather than including in OpenPojo library for convenience?
I confirm @oshoukry comment, add this dependency help to resolve this issue. To summary my context, I testing my existing code (jdk8) for jdk13 and this error happens. I think this is due to the changes between 8 and 12.
I'm having the same problem, but in JDK 8 (OpenJDK 1.8.0_212). Any help would be appreciated, or maybe it can help get to the bottom of a problem. Thanks!
I'm using:
<dependency>
<groupId>com.openpojo</groupId>
<artifactId>openpojo</artifactId>
<version>0.8.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>8.0.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
And the test code:
package org.openpojo;
import com.openpojo.reflection.impl.PojoClassFactory;
import com.openpojo.validation.ValidatorBuilder;
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
import org.testng.annotations.Test;
public class OPJFailure {
@Test
public void testValidateAccessors_Pass() throws Exception {
ValidatorBuilder.create()
.with(new GetterTester())
.with(new SetterTester())
.build().validate(PojoClassFactory.getPojoClass(PassClassAbstract.class));
}
@Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = "Getter returned non equal value for field.*")
public void testValidateAccessorsAbstract_Fail() throws Exception {
ValidatorBuilder.create()
.with(new GetterTester())
.with(new SetterTester())
.build().validate(PojoClassFactory.getPojoClass(FailClassAbstract.class));
}
private static abstract class FailClassAbstract {
private int test;
public int getTest() {
return -1;
}
public void setTest(int test) {
this.test = 0;
}
public abstract int doesSomething();
}
private static abstract class PassClassAbstract {
private int test;
public int getTest() {
return test;
}
public void setTest(int test) {
this.test = test;
}
public abstract int doesSomething();
}
}
Hello Team,
Unable to cover Getter and Setter of any Abstract class or derived class having abstract class extended Kindly help me out to cover it . Let me know how can cover Getter and setter of any Abstarct class. :) Getting below error com.openpojo.reflection.exception.ReflectionException: Failed to create instance for class [com.openpojo.reflection.impl.PojoClassImpl ....
Thanks Jyotsna