mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-01-10 20:30:11 +08:00
mock target is always in parameter when recording
This commit is contained in:
parent
02c74299f4
commit
b4a29e7e8e
@ -25,7 +25,7 @@ public class MockClassHandler extends BaseClassWithContextHandler {
|
||||
private static final String SIGNATURE_INVOKE_ORIGIN =
|
||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;";
|
||||
private static final String METHOD_RECORD_MOCK_INVOKE = "recordMockInvoke";
|
||||
private static final String SIGNATURE_RECORDER_METHOD_INVOKE = "([Ljava/lang/Object;ZZ)V";
|
||||
private static final String SIGNATURE_RECORDER_METHOD_INVOKE = "([Ljava/lang/Object;Z)V";
|
||||
private static final String METHOD_IS_ASSOCIATED = "isAssociated";
|
||||
private static final String SIGNATURE_IS_ASSOCIATED = "()Z";
|
||||
|
||||
@ -188,7 +188,6 @@ public class MockClassHandler extends BaseClassWithContextHandler {
|
||||
} else {
|
||||
il.add(new InsnNode(ICONST_0));
|
||||
}
|
||||
il.add(new InsnNode(ICONST_1));
|
||||
il.add(new MethodInsnNode(INVOKESTATIC, CLASS_INVOKE_RECORD_UTIL, METHOD_RECORD_MOCK_INVOKE,
|
||||
SIGNATURE_RECORDER_METHOD_INVOKE, false));
|
||||
mn.instructions.insertBefore(mn.instructions.getFirst(), il);
|
||||
|
@ -16,9 +16,8 @@ public class InvokeRecordUtil {
|
||||
* Record mock method invoke event
|
||||
* @param args invocation parameters
|
||||
* @param isConstructor whether mocked method is constructor
|
||||
* @param isTargetClassInParameter whether use first parameter as target class
|
||||
*/
|
||||
public static void recordMockInvoke(Object[] args, boolean isConstructor, boolean isTargetClassInParameter) {
|
||||
public static void recordMockInvoke(Object[] args, boolean isConstructor) {
|
||||
StackTraceElement mockMethodTraceElement = Thread.currentThread().getStackTrace()[INDEX_OF_TEST_CLASS];
|
||||
String mockMethodName = mockMethodTraceElement.getMethodName();
|
||||
MockContext mockContext = MockContextUtil.context.get();
|
||||
@ -32,7 +31,7 @@ public class InvokeRecordUtil {
|
||||
mockContext.invokeRecord.get(mockMethodName).add(args);
|
||||
LogUtil.verbose(" Mock constructor \"%s\" invoked in %s::%s", mockMethodName, testClass, testCaseName);
|
||||
} else {
|
||||
mockContext.invokeRecord.get(mockMethodName).add(isTargetClassInParameter ? slice(args, 1) : args);
|
||||
mockContext.invokeRecord.get(mockMethodName).add(slice(args, 1));
|
||||
LogUtil.verbose(" Mock method \"%s\" invoked in %s::%s\"", mockMethodName, testClass, testCaseName);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user