You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by yx...@apache.org on 2023/03/01 15:27:41 UTC

[shardingsphere] branch master updated: Update code conduct (#24411)

This is an automated email from the ASF dual-hosted git repository.

yx9o pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 5b49b450592 Update code conduct (#24411)
5b49b450592 is described below

commit 5b49b45059208728be13dbaa2132faa05e5338e3
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Wed Mar 1 23:27:30 2023 +0800

    Update code conduct (#24411)
---
 docs/community/content/involved/conduct/code.cn.md | 3 ++-
 docs/community/content/involved/conduct/code.en.md | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/docs/community/content/involved/conduct/code.cn.md b/docs/community/content/involved/conduct/code.cn.md
index ae750ce7690..39e3b269726 100644
--- a/docs/community/content/involved/conduct/code.cn.md
+++ b/docs/community/content/involved/conduct/code.cn.md
@@ -86,10 +86,11 @@ chapter = true
     - 其他类型应使用 `assertThat`。
  - 测试用例的真实值应名为为 actual XXX,期望值应命名为 expected XXX。
  - 测试类和 `@Test` 标注的方法无需 javadoc。
- - 使用 Mockito `mockStatic` 和 `mockConstruction` 方法必须搭配 try-with-resource 或在清理方法中关闭,避免泄漏。
  - 使用 `mock` 应遵循如下规范:
    - 单元测试需要连接某个环境时,应使用 `mock`;
    - 单元测试包含不容易构建的对象时,例如:超过两层嵌套并且和测试无关的对象,应使用 `mock`。
+   - 模拟静态方法或构造器,应优先考虑使用测试框架提供的 `AutoMockExtension` 和 `StaticMockSettings` 自动释放资源;若使用 Mockito `mockStatic` 和 `mockConstruction` 方法,必须搭配 `try-with-resource` 或在清理方法中关闭,避免泄漏。
+   - 校验仅有一次调用时,无需使用 `times(1)` 参数,使用 `verify` 的单参数方法即可。
 
 ## G4 编码规范
 
diff --git a/docs/community/content/involved/conduct/code.en.md b/docs/community/content/involved/conduct/code.en.md
index fcc8fade1a8..351c7108721 100644
--- a/docs/community/content/involved/conduct/code.en.md
+++ b/docs/community/content/involved/conduct/code.en.md
@@ -89,6 +89,8 @@ The following code of conduct is based on full compliance with [ASF CODE OF COND
  - Using `mock` should follow following specifications:
    - Using `mock` when unit tests need to connect to an environment;
    - Using `mock` when unit tests contain objects that are not easy to build, for example, objects that are more than two layers nested and unrelated to the test.
+   - When mocking static methods or constructors, it is recommended to use the testing framework's `AutoMockExtension` and `StaticMockSettings` to release resources automatically; If using Mockito's `mockStatic` and `mockConstruction` methods, please use `try-with-resource` or close them in the cleanup method to avoid resource leaks.
+   - When verifying only one invocation, there is no need to use `times(1)` parameter, please use the single-argument method of `verify`.
 
 ## Contributor Covenant G4 Code of Conduct