Skip to content

Commit

Permalink
Warn about practices that lead to flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo committed Apr 1, 2024
1 parent 2871210 commit 8e352df
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ We recommend you use IntelliJ as your IDE. The code style template for the proje
* Categorize errors when throwing an exception
* **Tests**
* Avoid adding `Thread.sleep` in tests--these can fail due to environmental conditions, such as garbage collection or noisy neighbors in the CI environment.
* Do not use random values in tests. All tests should be reproducible.
* Be careful when storing test data in fields because doing so is
only appropriate for constant, immutable values. Presto tests
run with TestNG which, unlike JUnit, does not create a new object for
each test. Shared instance fields can make tests tightly coupled,
order dependent, and flaky. If you do use instance fields,
reinitialize them before each test in a `@BeforeMethod` method,
and annotate the class with `@Test(singleThreaded = true)`.


## Commit Standards
Expand Down

0 comments on commit 8e352df

Please sign in to comment.