We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
被mock类: /**
演示使用@MockContainer注解实现Mock容器类的多重继承
Demonstrate multiple inherit of mock container class with @MockContainer annotation */ public class DemoMultipleInherit {
private String prefix() { return "ori_"; }
private String middle() { return "gin"; }
public void ss(){ System.out.println("abd"); }
private String suffix(int some, String more, Object[] parameters) { return "_al"; }
public String entry() { return prefix() + middle() + suffix(0, null, null); }
}
mock类代码:
/**
Demonstrate multiple inherit of mock container class with @MockContainer annotation */ class DemoMultipleInheritTest {
private DemoMultipleInherit demoMultipleInherit = new DemoMultipleInherit();
public static class PrefixMock { @MockInvoke(targetClass = DemoMultipleInherit.class) private String prefix() { return "in_"; } }
public static class SuffixMock { @MockInvoke(targetClass = DemoMultipleInherit.class) private String suffix(int some, String more, Object[] parameters) { return "_it"; }
@MockInvoke(targetClass = DemoMultipleInherit.class) private void ss(){ System.out.println("aaaddd"); }
@MockContainer(inherits = { PrefixMock.class, SuffixMock.class }) public static class Mock { @MockInvoke(targetClass = DemoMultipleInherit.class) private String middle() { return "her"; } }
@test public void should_use_mock_method_in_parent_class() { assertEquals("in_her_it", demoMultipleInherit.entry()); demoMultipleInherit.ss(); verifyInvoked("prefix").withTimes(1); verifyInvoked("middle").withTimes(1); verifyInvoked("suffix").withTimes(1); } }
异常提示: java.lang.VerifyError: Operand stack underflow Exception Details: Location: com/alibaba/demo/inherit/DemoMultipleInheritTest$Mock.ss(Lcom/alibaba/demo/inherit/DemoMultipleInherit;)V @7: areturn Reason: Attempt to pop empty stack. Current Frame: bci: @7 flags: { } locals: { 'com/alibaba/demo/inherit/DemoMultipleInheritTest$Mock', 'com/alibaba/demo/inherit/DemoMultipleInherit' } stack: { } Bytecode: 0x0000000: b800 392b b600 3fb0
The text was updated successfully, but these errors were encountered:
No branches or pull requests
被mock类:
/**
演示使用@MockContainer注解实现Mock容器类的多重继承
Demonstrate multiple inherit of mock container class with @MockContainer annotation
*/
public class DemoMultipleInherit {
private String prefix() {
return "ori_";
}
private String middle() {
return "gin";
}
public void ss(){
System.out.println("abd");
}
private String suffix(int some, String more, Object[] parameters) {
return "_al";
}
public String entry() {
return prefix() + middle() + suffix(0, null, null);
}
}
mock类代码:
/**
演示使用@MockContainer注解实现Mock容器类的多重继承
Demonstrate multiple inherit of mock container class with @MockContainer annotation
*/
class DemoMultipleInheritTest {
private DemoMultipleInherit demoMultipleInherit = new DemoMultipleInherit();
public static class PrefixMock {
@MockInvoke(targetClass = DemoMultipleInherit.class)
private String prefix() {
return "in_";
}
}
public static class SuffixMock {
@MockInvoke(targetClass = DemoMultipleInherit.class)
private String suffix(int some, String more, Object[] parameters) {
return "_it";
}
}
@MockContainer(inherits = { PrefixMock.class, SuffixMock.class })
public static class Mock {
@MockInvoke(targetClass = DemoMultipleInherit.class)
private String middle() {
return "her";
}
}
@test
public void should_use_mock_method_in_parent_class() {
assertEquals("in_her_it", demoMultipleInherit.entry());
demoMultipleInherit.ss();
verifyInvoked("prefix").withTimes(1);
verifyInvoked("middle").withTimes(1);
verifyInvoked("suffix").withTimes(1);
}
}
异常提示:
java.lang.VerifyError: Operand stack underflow
Exception Details:
Location:
com/alibaba/demo/inherit/DemoMultipleInheritTest$Mock.ss(Lcom/alibaba/demo/inherit/DemoMultipleInherit;)V @7: areturn
Reason:
Attempt to pop empty stack.
Current Frame:
bci: @7
flags: { }
locals: { 'com/alibaba/demo/inherit/DemoMultipleInheritTest$Mock', 'com/alibaba/demo/inherit/DemoMultipleInherit' }
stack: { }
Bytecode:
0x0000000: b800 392b b600 3fb0
The text was updated successfully, but these errors were encountered: