From b3b3dc0d58512cd2240f92eabb2ff86320341d15 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Mon, 22 Apr 2024 14:13:38 +0200 Subject: [PATCH] Update documentation: Prevent creating AemContext instances within BeforeEach/BeforeAll --- src/site/markdown/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/markdown/usage.md b/src/site/markdown/usage.md index 2d1afee3..fadb9e8c 100644 --- a/src/site/markdown/usage.md +++ b/src/site/markdown/usage.md @@ -44,7 +44,7 @@ public class ExampleTest { It is possible to combine such a unit test with a `@ExtendWith` annotation e.g. for [Mockito JUnit Jupiter Extension][mockito-junit5-extension]. -It is recommended to define the AemContext field as non-static field and use `@BeforeEach` and `@AfterEach` methods if you want to execute setup or tear down code for each test run. Since version 3.0.0 AEM Mocks also supports static AemContext fields and `@BeforeAll` and `@AfterAll` methods. However, you have to make sure you have no side-effects between the tests, as all changes in the AemContext object (e.g. content written to repository or OSGi services registered) are visible to all tests in the class. +It is recommended to define the AemContext field as non-static field and use `@BeforeEach` and `@AfterEach` methods if you want to execute setup or tear down code for each test run. Since version 3.0.0 AEM Mocks also supports static AemContext fields and `@BeforeAll` and `@AfterAll` methods. However, you have to make sure you have no side-effects between the tests, as all changes in the AemContext object (e.g. content written to repository or OSGi services registered) are visible to all tests in the class. You should never try to instantiate an AemContext object within a `@BeforeEach` or `@BeforeAll` method, this may lead to duplicate context instances. ### JUnit 4: AEM Context JUnit Rule