diff --git a/docs/en-us/doc/setup.md b/docs/en-us/doc/setup.md index f25669c..ac80fec 100644 --- a/docs/en-us/doc/setup.md +++ b/docs/en-us/doc/setup.md @@ -6,7 +6,8 @@ Use TestableMock - [Quickly mock arbitrary call](en-us/doc/use-mock.md): quickly replace any method invocation in the class under test with a mock method, solve the cumbersome use of traditional mock tools problem - [Access private members of the class under test](en-us/doc/private-accessor.md): enable unit tests directly invoke or access private members of the class under test, solve the problems of private member initialization and private method testing - [Quickly construct complicated parameter object](en-us/doc/omni-constructor.md):generate arbitrarily nested object instances, simplify their internal member assignment methods, solve the problem of long initialization codes for method parameters -- [Auxiliary test void method](en-us/doc/test-void-method.md): use the mock validator to check the internal logic of method, solve the problem that unit testing is difficult to implement to the method with no return value +- [Assist test void method](en-us/doc/test-void-method.md): use the mock validator to check the internal logic of method, solve the problem that unit testing is difficult to implement to the method with no return value +- [Assist test SQL generated by mybatis](en-us/doc/test-mybatis-sql.md): provide built-in mock implementation for mybatis, solve the problem that the logic in data-access-object (DAO) layer cannot be tested directly ## Use in Maven project @@ -78,7 +79,7 @@ test { See the [build.gradle](https://github.com/alibaba/testable-mock/blob/master/demo/java-demo/build.gradle) file of project `java-demo` and the [build.gradle.kts](https://github.com/alibaba/testable-mock/blob/master/demo/kotlin-demo/build.gradle.kts) file of project `kotlin-demo`. -> For Android project tested with `Robolectric` framework, please use the same method to add `TestableMock` dependency as above, and add `javaagent` configuration as follows: +> For Android project, please use the same method to add `TestableMock` dependency as above, and add `javaagent` configuration as follows: > > ```groovy > android { @@ -92,7 +93,7 @@ See the [build.gradle](https://github.com/alibaba/testable-mock/blob/master/demo > } > ``` > -> See [issue-43](https://github.com/alibaba/testable-mock/issues/43) for a complete example. +> See project `demo/android-demo` for a complete example. > If the project is using `Spock` test framework, you need to specify the bytecode version generated by `Groovy` to be 1.6 or above, the method is as follows (please modify the properties value according to the actual JVM version used). > diff --git a/docs/en-us/doc/test-mybatis-sql.md b/docs/en-us/doc/test-mybatis-sql.md new file mode 100644 index 0000000..8b9ab7f --- /dev/null +++ b/docs/en-us/doc/test-mybatis-sql.md @@ -0,0 +1,4 @@ +Test Data Access Object +--- + +Plan to coming in version `0.7`. diff --git a/docs/zh-cn/doc/setup.md b/docs/zh-cn/doc/setup.md index 3cb614b..830bd88 100644 --- a/docs/zh-cn/doc/setup.md +++ b/docs/zh-cn/doc/setup.md @@ -7,6 +7,7 @@ - [访问被测类私有成员](zh-cn/doc/private-accessor.md):使单元测试能直接调用和访问被测类的私有成员,解决私有成员初始化和私有方法测试的问题 - [快速构造参数对象](zh-cn/doc/omni-constructor.md):生成任意复杂嵌套的对象实例,并简化其内部成员赋值方式,解决被测方法参数初始化代码冗长的问题 - [辅助测试void方法](zh-cn/doc/test-void-method.md):利用Mock校验器对方法的内部逻辑进行检查,解决无返回值方法难以实施单元测试的问题 +- [快速测试数据库SQL](zh-cn/doc/test-mybatis-sql.md):通过内置针对性的Mock实现,解决基于Mybatis的数据访问层(DAO层)代码逻辑无法直接测试的问题 ## 在Maven项目中使用 @@ -78,7 +79,7 @@ test { 参见项目`java-demo`的[build.gradle](https://github.com/alibaba/testable-mock/blob/master/demo/java-demo/build.gradle)和`kotlin-demo`的[build.gradle.kts](https://github.com/alibaba/testable-mock/blob/master/demo/kotlin-demo/build.gradle.kts)文件。 -> 若是基于`Robolectric`框架的Android项目,则添加`TestableMock`依赖方法同上,添加javaagent配置方法如下: +> 若用于Android项目,则添加`TestableMock`依赖方法同上,添加javaagent配置方法如下: > > ```groovy > android { @@ -92,7 +93,7 @@ test { > } > ``` > -> 完整示例参考[issue-43](https://github.com/alibaba/testable-mock/issues/43) +> 完整代码可参考`demo/android-demo`示例项目。 > 若项目使用`Spock`测试框架,需指定`Groovy`编译生成的JVM 1.6或以上版本字节码,方法如下(请根据实际使用的JVM版本修改属性值)。 > diff --git a/docs/zh-cn/doc/test-mybatis-sql.md b/docs/zh-cn/doc/test-mybatis-sql.md new file mode 100644 index 0000000..40cc8ff --- /dev/null +++ b/docs/zh-cn/doc/test-mybatis-sql.md @@ -0,0 +1,6 @@ +测试数据访问层逻辑 +--- + +由于数据库的访问本质上属于外部调用,因此在单元测试中往往被作为Mock的目标,导致DAO层逻辑很容易成为单元测试盲区。为此`TestableMock`通过针对`Mybatis`内部逻辑的精准Mock,提供按需拦截和验证实际SQL语句的功能。 + +计划在`0.7`版本中推出。