mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-01-24 03:10:14 +08:00
test class package should match the class under test
This commit is contained in:
parent
2d8433056c
commit
8d33cb718f
@ -7,7 +7,7 @@ Compared with the class-granularity mocking practices of existing mock tools, `T
|
||||
> - Mock non-constructive method, copy the original method definition to the test class, add a parameter of the same type as the caller, and add a `@MockMethod` annotation
|
||||
> - Mock construction method, copy the original method definition to the test class, replace the return value with the constructed type, the method name is arbitrary, and add a `@MockContructor` annotation
|
||||
|
||||
> **Note**: There is also a convention in the current version that the name of the test class should be `<NameOfClassUnderTest> + Test`, which is usually the by-default naming convention of Java unit tests. This constraint may be relaxed or removed in future versions of `TestableMock`.
|
||||
> **Note**: There is also a convention in the current version that the name of the test class should be `<NameOfClassUnderTest> + Test` (and in the same package path), which is usually the by-default naming convention of Java project managed by `Maven` or `Gradle`. This constraint may be relaxed or removed in future versions of `TestableMock`.
|
||||
|
||||
The detail mock method definition convention is as follows:
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
> - Mock非构造方法,拷贝原方法定义到测试类,增加一个与调用者类型相同的参数,加`@MockMethod`注解
|
||||
> - Mock构造方法,拷贝原方法定义到测试类,返回值换成构造的类型,方法名随意,加`@MockContructor`注解
|
||||
|
||||
> **注意**:当前版本还有一项约定是,测试类名称应该为`被测类名+Test`,通常Java单元测试均符合这种惯例。此约定在未来的`TestableMock`版本中可能会被放宽或去除。
|
||||
> **注意**:当前版本还有一项约定是,测试类与被测类的包路径应相同,且名称为`被测类名+Test`,通常采用`Maven`或`Gradle`构建的Java项目符合这种惯例。此约定在未来的`TestableMock`版本中可能会被放宽或去除。
|
||||
|
||||
具体的Mock方法定义约定如下:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user