add mock method scope

This commit is contained in:
金戟 2021-02-17 17:59:13 +08:00
parent c364e96f77
commit 6d6e2ecb7f
3 changed files with 32 additions and 0 deletions

View File

@ -1,5 +1,7 @@
package com.alibaba.testable.core.annotation;
import com.alibaba.testable.core.model.MockScope;
import java.lang.annotation.*;
/**
@ -11,4 +13,11 @@ import java.lang.annotation.*;
@Target(ElementType.METHOD)
@Documented
public @interface MockConstructor {
/**
* specify the effective scope of the mock method
* @return global or associated
*/
MockScope scope() default MockScope.ASSOCIATED;
}

View File

@ -1,5 +1,7 @@
package com.alibaba.testable.core.annotation;
import com.alibaba.testable.core.model.MockScope;
import javax.lang.model.type.NullType;
import java.lang.annotation.*;
@ -25,4 +27,10 @@ public @interface MockMethod {
*/
Class<?> targetClass() default NullType.class;
/**
* specify the effective scope of the mock method
* @return global or associated
*/
MockScope scope() default MockScope.ASSOCIATED;
}

View File

@ -0,0 +1,15 @@
package com.alibaba.testable.core.model;
public enum MockScope {
/**
* Mock method only available for test cases in the test class it belongs to
*/
ASSOCIATED,
/**
* Mock method available for any test cases
*/
GLOBAL
}