Thanks for the quick reply
To explain further regarding the above issue , here is the small example.
These are two public java classes .
Class A:
public class A(){
int a;
public A(){}
public int Method1(){
a=10;
return a;
}
}
Class B:
public class B(){
int b;
private A object_of_a;
public B(){}
public int method2(){
int c= object_of_a.Method1();
b=b+c;
return c;
}
}
This is a Unit Test Class which is written for Class B. In this unit test case i m using Jmockit for mocking some of the methods.
In the Below Test Case i m mocking the method Method1() of Class A using Jmockit and I use Jacoco agent to run the test case.
import org.testng.annotations.Test;
import org.junit.runner.RunWith;
import mockit.MockUp;
import mockit.Mock;
@Test
@RunWith(JMockit.class)
public class Test_B(){
public Test_B(){}
@BeforeClass
public void setup() throws Exception {
}
@Test
public void test_method2(){
new MockUp(A){ < -- 10 ( Here i get Exception)
@Mock
public int Method1(){
return 1290;
}
};
B b = new B();
int res = b.method2();
}
}
Now , I execute my Test Case Test_B(). For this i use jacoco - maven -plugin 0.7.9 and Jmockit version 1.28.
When i execute the testcase with these two configuarations , My testcase is getting failed at Line 10 which is mentioned above with the exception -- > "java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the schema (add/remove fields)".
And,if i remove Jacoco plugin and just execute the test case as a normal test case without any jacoco agent in the command and using just jmockit version, It's works fine without any exception. So i m facing this issue when both jacoco and jmockit are used together.
I want to know how to solve this conflct or is this a bug in Jacoco version 0.7.9 which is not working fine with other plugins like Jmockit.
Thanks,
-Praveen