diff --git a/topics/basics/testing_plugins/testing_faq.md b/topics/basics/testing_plugins/testing_faq.md index 7354e73cb..1fe9bb5ce 100644 --- a/topics/basics/testing_plugins/testing_faq.md +++ b/topics/basics/testing_plugins/testing_faq.md @@ -39,6 +39,9 @@ Please see [notes](api_changes_list_2021.md#20213). Always call `super.tearDown()` inside `finally {..}` block of your test class to avoid leaks and side effects from previously run (failed) tests: + + + ```java protected void tearDown() throws Exception { try { @@ -52,6 +55,25 @@ protected void tearDown() throws Exception { } } ``` + + + + +```kotlin +override fun tearDown() { + try { + // test specific tear down calls + } + catch (e: Throwable) { + addSuppressedException(e) + } + finally { + super.tearDown() + } +} +``` + + Avoid OS-specific assumptions (e.g., filesystem case-sensitivity, hardcoded separator instead of `java.io.File.separator`, default encoding, line endings). @@ -156,7 +178,7 @@ It's done by setting the `idea.home.path` system property to the absolute path o - + ```kotlin test { @@ -165,7 +187,7 @@ test { ``` - + ```groovy test {