You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description of the problem or enhancement request:
When attempting to test a delegate class, and an highly simplified case would be:
public static class MyClass implements Runnable {
private Runnable r;
public MyClass(Runnable r) {
this.r = r;
}
public Runnable getRun() {
return r;
}
public void run() {
getRun().run();
}
}
And attempting to perform a partial mock on the class to isolate in the above example the run() method from the getRun() method, and example test would be:
@Test
public void testMe(final @Injectable Runnable mockedRunnable) {
final MyClass instance = new MyClass(mockedRunnable);
new Expectations(instance) {
{
instance.getRun();
result = new Runnable() {
public void run() {
System.out.print("Expectation runnable");
}
};
}
};
instance.run();
}
One gets: java.lang.IllegalArgumentException: Already mocked: interface java.lang.Runnable
Removing the extends Runnable on the class solves the error, but makes the delegate useless.
Any ideas?
The text was updated successfully, but these errors were encountered:
Please provide the following information:
Version of JMockit that was used: 1,21
Description of the problem or enhancement request:
When attempting to test a delegate class, and an highly simplified case would be:
public static class MyClass implements Runnable {
private Runnable r;
}
And attempting to perform a partial mock on the class to isolate in the above example the run() method from the getRun() method, and example test would be:
One gets: java.lang.IllegalArgumentException: Already mocked: interface java.lang.Runnable
Removing the extends Runnable on the class solves the error, but makes the delegate useless.
Any ideas?
The text was updated successfully, but these errors were encountered: