From d49f52637604d9f77035ddc8344d1553a3e28bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E6=88=9F?= Date: Tue, 23 Feb 2021 13:12:23 +0800 Subject: [PATCH] add placeholder for english docs --- README_EN.md | 5 ++--- docs/en-us/doc/annotations.md | 4 ++++ docs/en-us/doc/design-and-mechanism.md | 4 ++++ docs/en-us/doc/javaagent-args.md | 4 ++++ docs/en-us/doc/mock-method-reusing.md | 4 ++++ docs/en-us/doc/scope-of-mock.md | 4 ++++ docs/en-us/doc/upgrade-to-v05.md | 2 +- docs/en-us/doc/use-mock-with.md | 4 ++++ docs/en-us/sidebar.md | 8 +++++++- docs/zh-cn/doc/frequently-asked-questions.md | 8 ++++++-- docs/zh-cn/doc/use-mock-with.md | 2 +- 11 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 docs/en-us/doc/annotations.md create mode 100644 docs/en-us/doc/design-and-mechanism.md create mode 100644 docs/en-us/doc/javaagent-args.md create mode 100644 docs/en-us/doc/mock-method-reusing.md create mode 100644 docs/en-us/doc/scope-of-mock.md create mode 100644 docs/en-us/doc/use-mock-with.md diff --git a/README_EN.md b/README_EN.md index b6b5e0c..3241b15 100644 --- a/README_EN.md +++ b/README_EN.md @@ -11,9 +11,8 @@ Usage Document: https://alibaba.github.io/testable-mock/#/en-us/ `TestableMock` is still under heavy development, the following version plans may be adjusted during the iteration -- `v0.4` it's the current version, refer to the [issue](https://github.com/alibaba/testable-mock/issues) list for the work in progress -- `v0.5` implementation mock class inherit mechanism, so that the same mock method can be reused between test classes conveniently -- `v0.6` narrows the default effective scope of mock methods to the class under test, to avoid interaction of mocking cross classes +- `v0.5` it's the current version, refer to the [issue](https://github.com/alibaba/testable-mock/issues) list for the work in progress +- `v0.6` implement the functionality of "parameter constructor" - `v1.0` all functions are stable, a brand-new start ## Directory Structure diff --git a/docs/en-us/doc/annotations.md b/docs/en-us/doc/annotations.md new file mode 100644 index 0000000..34b849f --- /dev/null +++ b/docs/en-us/doc/annotations.md @@ -0,0 +1,4 @@ +Available Annotations +--- + +TO BE TRANSLATED diff --git a/docs/en-us/doc/design-and-mechanism.md b/docs/en-us/doc/design-and-mechanism.md new file mode 100644 index 0000000..8ee2a13 --- /dev/null +++ b/docs/en-us/doc/design-and-mechanism.md @@ -0,0 +1,4 @@ +How Mock Works +--- + +TO BE TRANSLATED diff --git a/docs/en-us/doc/javaagent-args.md b/docs/en-us/doc/javaagent-args.md new file mode 100644 index 0000000..ef488ec --- /dev/null +++ b/docs/en-us/doc/javaagent-args.md @@ -0,0 +1,4 @@ +Available Global Arguments +--- + +TO BE TRANSLATED diff --git a/docs/en-us/doc/mock-method-reusing.md b/docs/en-us/doc/mock-method-reusing.md new file mode 100644 index 0000000..fc3803c --- /dev/null +++ b/docs/en-us/doc/mock-method-reusing.md @@ -0,0 +1,4 @@ +Reusing Mock Methods +--- + +TO BE TRANSLATED diff --git a/docs/en-us/doc/scope-of-mock.md b/docs/en-us/doc/scope-of-mock.md new file mode 100644 index 0000000..e76d103 --- /dev/null +++ b/docs/en-us/doc/scope-of-mock.md @@ -0,0 +1,4 @@ +Effective Scope Of Mocking +--- + +TO BE TRANSLATED diff --git a/docs/en-us/doc/upgrade-to-v05.md b/docs/en-us/doc/upgrade-to-v05.md index 5a6217b..fb7c2c2 100644 --- a/docs/en-us/doc/upgrade-to-v05.md +++ b/docs/en-us/doc/upgrade-to-v05.md @@ -1,4 +1,4 @@ -Upgrade to version 0.5 +Upgrade To Version 0.5 --- After nearly a month of design and development, the `0.5` version of TestableMock has finally come out. Compared with the `0.4` version, the new version solves the three historical problems left over before: diff --git a/docs/en-us/doc/use-mock-with.md b/docs/en-us/doc/use-mock-with.md new file mode 100644 index 0000000..41ffc62 --- /dev/null +++ b/docs/en-us/doc/use-mock-with.md @@ -0,0 +1,4 @@ +Use MockWith Annotation +--- + +TO BE TRANSLATED diff --git a/docs/en-us/sidebar.md b/docs/en-us/sidebar.md index 310d5a4..6dada06 100644 --- a/docs/en-us/sidebar.md +++ b/docs/en-us/sidebar.md @@ -7,13 +7,19 @@ - Usage Guide - [Verify Mock Invocation](en-us/doc/invoke-matcher.md) + - [Effective Scope Of Mocking](zh-cn/doc/scope-of-mock.md) + - [Reusing Mock Methods](zh-cn/doc/mock-method-reusing.md) + - [Use MockWith Annotation](zh-cn/doc/use-mock-with.md) - [Frequently Asked Questions](en-us/doc/frequently-asked-questions.md) - [Use TestableMock In IDE](en-us/doc/use-in-ide.md) - [Self-Help Troubleshooting](en-us/doc/troubleshooting.md) - [Testable Maven Plugin](en-us/doc/use-maven-plugin.md) - Technical Reference - - [Upgrade To 0.5 Version](en-us/doc/upgrade-to-v05.md) + - [Upgrade To Version 0.5](en-us/doc/upgrade-to-v05.md) + - [Available Global Arguments](zh-cn/doc/javaagent-args.md) + - [Available Annotations](zh-cn/doc/annotations.md) + - [How Mock Works](zh-cn/doc/design-and-mechanism.md) - [Mock Tools Comparison](en-us/doc/comparation.md) - [Release Note](en-us/doc/release-note.md) - [About Us](en-us/doc/about-us.md) diff --git a/docs/zh-cn/doc/frequently-asked-questions.md b/docs/zh-cn/doc/frequently-asked-questions.md index 493b98e..547979e 100644 --- a/docs/zh-cn/doc/frequently-asked-questions.md +++ b/docs/zh-cn/doc/frequently-asked-questions.md @@ -1,9 +1,13 @@ 常见使用问题 --- -#### 1. 如何Mock被测类中通过`@Autowired`初始化的字段? +#### 1. 如何初始化被测类中通过`@Autowired`或`@Resource`注入的私有字段? -直接创建被测类对象,然后利用`TestableMock`访问私有成员的能力直接给这些字段赋值即可。 +若该对象的方法在测试时需要被Mock,则无需初始化。 + +若测试运行时需用到该对象的真实调用,则可以在测试类的构造方法内直接创建对象,然后利用`TestableMock`访问私有成员的能力给这些字段赋值。 + +对于JUnit框架,还可以使用`@RunWith(SpringRunner.class)`注解将Spring上下文启动起来,然后在测试类里用`@Resource`把需要依赖对象注入进来,再利用`PrivateAccessor`赋值给被测类的私有字段。 #### 2. `TestableMock`是否能够与其他Mock工具一起使用? diff --git a/docs/zh-cn/doc/use-mock-with.md b/docs/zh-cn/doc/use-mock-with.md index c95f06e..d8fbccc 100644 --- a/docs/zh-cn/doc/use-mock-with.md +++ b/docs/zh-cn/doc/use-mock-with.md @@ -88,7 +88,7 @@ public class ServiceTest { 完整代码示例见`java-demo`和`kotlin-demo`示例项目中`OneToMultiSvcTest`测试类的用例。 -> 由于当前版本里,测试类无法通过`@MockWith`与多个Mock容器关联,对生效范围为`MockScope.ASSOCIATED`的Mock方法会遇到Mock无效的情况,为已知BUG,将在未来版本中修复。 +> 由于当前版本里,测试类无法通过`@MockWith`与多个Mock容器关联,目前这种用法仅支持生效范围为`MockScope.GLOBAL`的Mock方法,这是已知BUG,将在未来版本中修复。 ### 4. 使用不包含Mock方法的Mock容器类