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

zhangliang 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 b20b792c900 Update unit test specification documentation (#22414)
b20b792c900 is described below

commit b20b792c900abffc0b9ea08ecc030e52039173fa
Author: ZhangCheng <[email protected]>
AuthorDate: Fri Nov 25 18:57:23 2022 +0800

    Update unit test specification documentation (#22414)
    
    * Update unit test specification documentation
    
    * Fix
---
 docs/community/content/involved/conduct/code.cn.md | 10 ++++------
 docs/community/content/involved/conduct/code.en.md |  8 +++-----
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/docs/community/content/involved/conduct/code.cn.md 
b/docs/community/content/involved/conduct/code.cn.md
index 7e8bc536955..900dd4c2161 100644
--- a/docs/community/content/involved/conduct/code.cn.md
+++ b/docs/community/content/involved/conduct/code.cn.md
@@ -77,15 +77,13 @@ chapter = true
    - 合理性设计(Design):与生产代码设计相结合,设计高质量的单元测试。
    - 容错性测试(Error):通过非法数据、异常流程等错误的输入,得到预期结果。
  - 除去简单的 `getter /setter` 方法,以及声明 SPI 的静态代码,如:`getType / getOrder`,单元测试需全覆盖。
- - 每个测试用例需精确断言。
+ - 每个测试用例需精确断言,尽量不使用 `not`、`containsString` 断言。
  - 准备环境的代码和测试代码分离。
  - 只有 Mockito,junit `Assert`,hamcrest `CoreMatchers` 和 `MatcherAssert` 相关可以使用 
static import。
- - 单数据断言,应使用 `assertTrue`,`assertFalse`,`assertNull` 和 `assertNotNull`。
- - 多数据断言,应使用 `assertThat`。
- - 精确断言,尽量不使用 `not`,`containsString` 断言。
- - 测试用例的真实值应命名为 actual XXX,期望值应命名为 expected XXX。
+ - 数据断言方法的使用:对于 boolean 类型的断言应使用 `assertTrue` 和 `assertFalse`,断言是否为空应使用 
`assertNull` 和 `assertNotNull`,其他场景应使用 `assertThat`。
+ - 测试用例的真实值应名为为 actual XXX,期望值应命名为 expected XXX。
  - 测试类和 `@Test` 标注的方法无需 javadoc。
- - 使用 Mockito mockStatic 和 mockConstruction 方法必须搭配 try-with-resource 
或在清理方法中关闭,避免泄漏。
+ - 使用 Mockito `mockStatic` 和 `mockConstruction` 方法必须搭配 try-with-resource 
或在清理方法中关闭,避免泄漏。
 
 ## G4 编码规范
 
diff --git a/docs/community/content/involved/conduct/code.en.md 
b/docs/community/content/involved/conduct/code.en.md
index 417dbcafe62..3fed4a823f1 100644
--- a/docs/community/content/involved/conduct/code.en.md
+++ b/docs/community/content/involved/conduct/code.en.md
@@ -75,15 +75,13 @@ The following code of conduct is based on full compliance 
with [ASF CODE OF COND
    - Error: Error value test, test for error input, exception to get expect 
result.
  - Without particular reasons, test cases should be fully covered.
  - Test cases should be fully covered expect simply `getter /setter` methods, 
and declared static codes of SPI, such as: `getType / getOrder`.
- - Every test case need precised assertion.
+ - Every test case need precised assertion, try not to use `not`, 
`containsString` to make assertions.
  - Environment preparation codes should be separate from test codes.
  - Only those that relate to `Mockito`, junit `Assert`, hamcrest 
`CoreMatchers` and `MatcherAssert` can use static import.
- - For single parameter asserts, `assertTrue`, `assertFalse`, `assertNull` and 
`assertNotNull` should be used.
- - For multiple parameter asserts, `assertThat` should be used.
- - For accurate asserts, try not to use `not`, `containsString` to make 
assertions.
+ - Usage of assertion methods: for boolean type asserts, `assertTrue` and 
`assertFalse` should be used, `assertNull` and `assertNotNull` should be used 
to assert whether the assertion is null, and `assertThat` should be used for 
other scenarios.
  - Actual values of test cases should be named `actualXXX`, expected values 
`expectedXXX`.
  - Class for test case and `@Test` annotation do not need javadoc.
- - Mockito mockStatic and mockConstruction methods must be used with 
try-with-resource or closed in the teardown method to avoid leaks.
+ - Mockito `mockStatic` and `mockConstruction` methods must be used with 
try-with-resource or closed in the teardown method to avoid leaks.
 
 ## Contributor Covenant G4 Code of Conduct
 

Reply via email to