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
I currently have a testsuite which has previously been running on TestNG 6.9.10 and JMockit 1.30. When updating it to TestNG 6.11 and JMockit 1.35 I run into errors on all my @Mocked and @Interface annotations in parameters for my tests. The error is that my expectations no longer mock the results of the methods in the mocked instance.
As I understood the documentation having @Mocked or @Injectable in a test parameter would mean they work the same as if they were a member with the annotation, but only accessable inside the scope of the test.
A minimal class replicating this problem is seen below. The intension is that both tests should work the same way, but in newer versions of JMockit the @Injectable pSet returns 0 as size instead of 10. Is this a user error by me, or is it a bug introduced in newer versions of JMockit?
import java.util.Set;
import mockit.Expectations;
import mockit.Injectable;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
@Test
public class MinimalJMockitExample {
@Injectable Set<String> mSet;
@Test
public void test1(){
new Expectations() {{
mSet.size();
result = 10;
}};
assertEquals(mSet.size(), 10);
}
@Test
public void test2(@Injectable Set<String> pSet){
new Expectations() {{
pSet.size();
result = 10;
}};
assertEquals(pSet.size(), 10);
}
}
The text was updated successfully, but these errors were encountered:
I currently have a testsuite which has previously been running on TestNG 6.9.10 and JMockit 1.30. When updating it to TestNG 6.11 and JMockit 1.35 I run into errors on all my
@Mocked
and@Interface
annotations in parameters for my tests. The error is that my expectations no longer mock the results of the methods in the mocked instance.As I understood the documentation having
@Mocked
or@Injectable
in a test parameter would mean they work the same as if they were a member with the annotation, but only accessable inside the scope of the test.A minimal class replicating this problem is seen below. The intension is that both tests should work the same way, but in newer versions of JMockit the
@Injectable
pSet returns 0 as size instead of 10. Is this a user error by me, or is it a bug introduced in newer versions of JMockit?The text was updated successfully, but these errors were encountered: