Skip to content

Commit

Permalink
Update documentation: Prevent creating AemContext instances within Be…
Browse files Browse the repository at this point in the history
…foreEach/BeforeAll
  • Loading branch information
stefanseifert committed Apr 22, 2024
1 parent 220c77e commit 1ff3c16
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/site/markdown/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1ff3c16

Please sign in to comment.