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

chesnay pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/flink-web.git

commit 987343ae5235e9478ba75f544bbf2d879cead382
Author: slinkydeveloper <[email protected]>
AuthorDate: Mon Nov 15 17:31:44 2021 +0100

    [FLINK-25059][tests] Document assertion conventions
    
    Signed-off-by: slinkydeveloper <[email protected]>
---
 contributing/code-style-and-quality-common.md | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/contributing/code-style-and-quality-common.md 
b/contributing/code-style-and-quality-common.md
index 9c415e2..3851ad8 100644
--- a/contributing/code-style-and-quality-common.md
+++ b/contributing/code-style-and-quality-common.md
@@ -331,6 +331,31 @@ Examples are in the RPC system, Network Stack, in the 
Task’s mailbox model, or
 
 
 
+## 7. Testing
+
+We are moving our codebase to [JUnit 
5](https://junit.org/junit5/docs/current/user-guide/) and 
[AssertJ](https://assertj.github.io/doc/) as our testing framework and 
assertions library of choice.
+
+Unless there is a specific reason, make sure you use JUnit 5 and AssertJ when 
contributing to Flink with new tests and even when modifying existing tests. 
Don't use Hamcrest, JUnit assertions and `assert` directive.
+Make your tests readable and don't duplicate assertions logic provided by 
AssertJ or by [custom 
assertions](https://assertj.github.io/doc/#assertj-core-custom-assertions) 
provided by some flink modules.
+For example, avoid:
+
+```java
+assert list.size() == 10;
+for (String item : list) {
+    assertTrue(item.length() < 10);
+}
+```
+
+And instead use:
+
+```java
+assertThat(list)
+    .hasSize(10)
+    .allMatch(item -> item.length() < 10);
+```
+
+
+
 
 
 <hr>

Reply via email to