From f660ccb88fb18b0dc30649a1b35aad9bbb43e73f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E6=88=9F?= Date: Fri, 19 Feb 2021 17:16:01 +0800 Subject: [PATCH] always look for outer mock class --- .../transformer/TestableClassTransformer.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/testable-agent/src/main/java/com/alibaba/testable/agent/transformer/TestableClassTransformer.java b/testable-agent/src/main/java/com/alibaba/testable/agent/transformer/TestableClassTransformer.java index 81fa0d0..786ae7f 100644 --- a/testable-agent/src/main/java/com/alibaba/testable/agent/transformer/TestableClassTransformer.java +++ b/testable-agent/src/main/java/com/alibaba/testable/agent/transformer/TestableClassTransformer.java @@ -115,16 +115,15 @@ public class TestableClassTransformer implements ClassFileTransformer { private String foundMockForTestClass(String className) { ClassNode cn = ClassUtil.getClassNode(className); - if (cn == null) { - return null; - } - String mockClass = lookForMockWithAnnotationAsTestClass(cn); - if (mockClass != null) { - return mockClass; - } - mockClass = lookForInnerMockClass(cn); - if (mockClass != null) { - return mockClass; + if (cn != null) { + String mockClass = lookForMockWithAnnotationAsTestClass(cn); + if (mockClass != null) { + return mockClass; + } + mockClass = lookForInnerMockClass(cn); + if (mockClass != null) { + return mockClass; + } } return lookForOuterMockClass(className); }