spring-framework/framework-docs/modules/ROOT/pages/testing/testcontext-framework
Sam Brannen ed83461021 Support parameter injection in @[Before|After]Transaction methods
Prior to this commit, @​BeforeTransaction and @​AfterTransaction
methods could not accept any arguments. This is acceptable with testing
frameworks such as JUnit 4 and TestNG that do not provide support for
parameter injection. However, users of JUnit Jupiter have become
accustomed to being able to accept arguments in lifecycle methods
annotated with JUnit's @​BeforeEach, @​AfterEach, etc.

As a follow up to the previous commit (see gh-31199), this commit
introduces first-class support for parameter injection in
@​BeforeTransaction and @​AfterTransaction methods, as demonstrated in
the following example.

@​BeforeTransaction
void verifyInitialDatabaseState(@Autowired DataSource dataSource) {
	// Use the DataSource to verify the initial DB state
}

Closes gh-30736
2023-09-10 20:15:26 +02:00
..
ctx-management Document best practices for inlined properties in @TestPropertySource 2023-08-16 17:27:18 +02:00
aot.adoc Merge branch '6.0.x' 2023-08-03 11:27:37 +03:00
application-events.adoc Fix migration to asciidoctor tabs 2023-05-09 12:15:43 +01:00
bootstrapping.adoc Split files 2023-05-04 15:35:05 +01:00
ctx-management.adoc Document test context failure threshold support in reference manual 2023-06-09 17:45:12 +02:00
executing-sql.adoc Migrate to Asciidoctor Tabs 2023-05-04 15:35:05 +01:00
fixture-di.adoc Migrate to Asciidoctor Tabs 2023-05-04 15:35:05 +01:00
key-abstractions.adoc Fix cross references 2023-05-04 15:35:05 +01:00
parallel-test-execution.adoc Fix cross references 2023-05-04 15:35:05 +01:00
support-classes.adoc Support parameter injection in @[Before|After]Transaction methods 2023-09-10 20:15:26 +02:00
tel-config.adoc Overhaul TestExecutionListener for Micrometer ObservationRegistry 2023-06-14 14:36:05 +02:00
test-execution-events.adoc Fix cross references 2023-05-04 15:35:05 +01:00
tx.adoc Support parameter injection in @[Before|After]Transaction methods 2023-09-10 20:15:26 +02:00
web-scoped-beans.adoc Migrate to Asciidoctor Tabs 2023-05-04 15:35:05 +01:00