我全局Mock了一个方法,然后同包下的两个测试文件,其中一个可以正常运行,另一个Mock方法无法被替换,比较日志发现没有找到
Mock class
有问题的日志
[INFO] Found source class com/xxx/ism/tool/storagedeploy/exception/DeployException
[TIP] Found method <init>
[TIP] Line 29, constructing "java.lang.Exception(java.lang.String)"
[TIP] Found method <init>
[TIP] Line 33, invoking "com.xxx.ism.tool.storagedeploy.exception.DeployErrorCode::getMsg() : java.lang.String"
[TIP] Line 33, constructing "com.xxx.ism.tool.storagedeploy.exception.DeployException(com.xxx.ism.tool.storagedeploy.exception.DeployErrorCode, java.lang.String)"
[TIP] Found method <init>
[TIP] Line 44, constructing "com.xxx.ism.tool.storagedeploy.exception.DeployException(com.xxx.ism.tool.storagedeploy.exception.DeployErrorCode)"
[TIP] Line 45, invoking "com.xxx.ism.tool.storagedeploy.exception.DeployException::getMsgByResources(java.lang.String, java.lang.Object[]) : java.lang.String"
[TIP] Line 45, mock method "getMsgByResources" used
[TIP] Line 45, invoking "com.xxx.ism.tool.storagedeploy.exception.DeployExceptionTest$Mock::getMsgByResources(com.xxx.ism.tool.storagedeploy.exception.DeployException, java.lang.String, java.lang.Object[]) : java.lang.String"
[TIP] Found method <init>
[TIP] Line 55, constructing "java.lang.Exception(java.lang.String)"
[TIP] Line 57, invoking "com.xxx.ism.tool.storagedeploy.exception.DeployException::getMsgByResources(java.lang.String, java.lang.Object[]) : java.lang.String"
[TIP] Line 57, mock method "getMsgByResources" used
[TIP] Line 57, invoking "com.xxx.ism.tool.storagedeploy.exception.DeployExceptionTest$Mock::getMsgByResources(com.xxx.ism.tool.storagedeploy.exception.DeployException, java.lang.String, java.lang.Object[]) : java.lang.String"
[TIP] Found method getMsgByResources
[TIP] Line 62, invoking "com.xxx.ism.tool.obase.utils.ResourceUtil::getUndefindStringReturnKey(java.lang.String) : java.lang.String"
[TIP] Line 64, invoking "com.xxx.ism.tool.obase.utils.ResourceUtil::getStringWithParams(java.lang.String, java.lang.Object[]) : java.lang.String"
[TIP] Found method getCode
[TIP] Found method getMsg
[TIP] Failed to detect test framework for org/apache/logging/log4j/core/config/plugins/util/ResolverUtil$Test
[INFO] Completed at Fri Sep 09 00:12:34 CST 2022
正常日志
[INFO] Start at Fri Sep 09 00:25:53 CST 2022
[INFO] TestableMock start at D:\codes\work\SmartKit\StorageTools\SmartKit_StorageDeploy\service\server
[INFO] Found test class com/xxx/ism/tool/storagedeploy/model/micro/LauncherTest
[TIP] Test case "should_pass_when_right"
[TIP] Test case "should_pass_when_len_is_0"
[TIP] Test case "should_throw_exception_when_len_less_than_16"
[TIP] Test case "should_throw_exception_when_have_spc_char"
[TIP] Test case "should_not_pass_when_right"
[TIP] Test case "should_pass_when_have_0_and_f"
[TIP] Test case "should_not_pass_when_name_right"
[TIP] Test case "should_not_pass_when_name"
[TIP] Test case "should_not_pass_when_start_not_with_right"
[TIP] Test case "should_pass_when_roce_id_right"
[INFO] Found 10 test cases
[TIP] Failed to detect test framework for org/junit/jupiter/api/Test
[INFO] Found source class com/xxx/ism/tool/storagedeploy/exception/DeployException
[TIP] Found method <init>
[TIP] Line 29, constructing "java.lang.Exception(java.lang.String)"
[TIP] Found method <init>
[TIP] Line 33, invoking "com.xxx.ism.tool.storagedeploy.exception.DeployErrorCode::getMsg() : java.lang.String"
[TIP] Line 33, constructing "com.xxx.ism.tool.storagedeploy.exception.DeployException(com.xxx.ism.tool.storagedeploy.exception.DeployErrorCode, java.lang.String)"
[TIP] Found method <init>
[TIP] Line 44, constructing "com.xxx.ism.tool.storagedeploy.exception.DeployException(com.xxx.ism.tool.storagedeploy.exception.DeployErrorCode)"
[TIP] Line 45, invoking "com.xxx.ism.tool.storagedeploy.exception.DeployException::getMsgByResources(java.lang.String, java.lang.Object[]) : java.lang.String"
[TIP] Line 45, mock method "getMsgByResources" used
[TIP] Line 45, invoking "com.xxx.ism.tool.storagedeploy.exception.DeployExceptionTest$Mock::getMsgByResources(com.xxx.ism.tool.storagedeploy.exception.DeployException, java.lang.String, java.lang.Object[]) : java.lang.String"
[TIP] Found method <init>
[TIP] Line 55, constructing "java.lang.Exception(java.lang.String)"
[TIP] Line 57, invoking "com.xxx.ism.tool.storagedeploy.exception.DeployException::getMsgByResources(java.lang.String, java.lang.Object[]) : java.lang.String"
[TIP] Line 57, mock method "getMsgByResources" used
[TIP] Line 57, invoking "com.xxx.ism.tool.storagedeploy.exception.DeployExceptionTest$Mock::getMsgByResources(com.xxx.ism.tool.storagedeploy.exception.DeployException, java.lang.String, java.lang.Object[]) : java.lang.String"
[TIP] Found method getMsgByResources
[TIP] Line 62, invoking "com.xxx.ism.tool.obase.utils.ResourceUtil::getUndefindStringReturnKey(java.lang.String) : java.lang.String"
[TIP] Line 64, invoking "com.xxx.ism.tool.obase.utils.ResourceUtil::getStringWithParams(java.lang.String, java.lang.Object[]) : java.lang.String"
[TIP] Found method getCode
[TIP] Found method getMsg
[INFO] Found mock class com/xxx/ism/tool/storagedeploy/exception/DeployExceptionTest$Mock
[TIP] Mock method "getMsgByResources" as "com.xxx.ism.tool.storagedeploy.exception.DeployException::getMsgByResources(java.lang.String, java.lang.Object[]) : java.lang.String"
[INFO] Found 1 mock methods
[TIP] Mock method "getMsgByResources" invoked in com.xxx.ism.tool.storagedeploy.model.micro.LauncherTest::should_throw_exception_when_len_less_than_16"
[TIP] Mock method "getMsgByResources" invoked in com.xxx.ism.tool.storagedeploy.model.micro.LauncherTest::should_throw_exception_when_len_less_than_16"
[TIP] Mock method "getMsgByResources" invoked in com.xxx.ism.tool.storagedeploy.model.micro.LauncherTest::should_not_pass_when_right"
[TIP] Mock method "getMsgByResources" invoked in com.xxx.ism.tool.storagedeploy.model.micro.LauncherTest::should_not_pass_when_right"
[TIP] Mock method "getMsgByResources" invoked in com.xxx.ism.tool.storagedeploy.model.micro.LauncherTest::should_throw_exception_when_have_spc_char"
[TIP] Mock method "getMsgByResources" invoked in com.xxx.ism.tool.storagedeploy.model.micro.LauncherTest::should_throw_exception_when_have_spc_char"
[TIP] Mock method "getMsgByResources" invoked in com.xxx.ism.tool.storagedeploy.model.micro.LauncherTest::should_not_pass_when_name"
[TIP] Mock method "getMsgByResources" invoked in com.xxx.ism.tool.storagedeploy.model.micro.LauncherTest::should_not_pass_when_name"
[TIP] Mock method "getMsgByResources" invoked in com.xxx.ism.tool.storagedeploy.model.micro.LauncherTest::should_not_pass_when_start_not_with_right"
[TIP] Mock method "getMsgByResources" invoked in com.xxx.ism.tool.storagedeploy.model.micro.LauncherTest::should_not_pass_when_start_not_with_right"
[INFO] Completed at Fri Sep 09 00:25:56 CST 2022
我全局Mock了一个方法,然后同包下的两个测试文件,其中一个可以正常运行,另一个Mock方法无法被替换,比较日志发现没有找到 Mock class 有问题的日志
正常日志