spring-framework/framework-docs/modules/ROOT/pages/testing
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
..
annotations Revise support for JSR-330 and Jakarta @Inject for autowiring test constructors 2023-09-08 19:29:28 +02:00
spring-mvc-test-framework Fix migration to asciidoctor tabs 2023-05-09 12:15:43 +01:00
testcontext-framework Support parameter injection in @[Before|After]Transaction methods 2023-09-10 20:15:26 +02:00
annotations.adoc Enable Section Summary TOC for small pages 2023-05-04 15:35:05 +01:00
appendix.adoc Trim IDs with parent 2023-05-04 15:35:05 +01:00
integration.adoc Fix cross references 2023-05-04 15:35:05 +01:00
introduction.adoc Enable Section Summary TOC for small pages 2023-05-04 15:35:05 +01:00
resources.adoc Fix cross references 2023-05-04 15:35:05 +01:00
spring-mvc-test-client.adoc Migrate to Asciidoctor Tabs 2023-05-04 15:35:05 +01:00
spring-mvc-test-framework.adoc Enable Section Summary TOC for small pages 2023-05-04 15:35:05 +01:00
support-jdbc.adoc Fix cross references 2023-05-04 15:35:05 +01:00
testcontext-framework.adoc Enable Section Summary TOC for small pages 2023-05-04 15:35:05 +01:00
unit.adoc Fix cross references 2023-05-04 15:35:05 +01:00
webtestclient.adoc Fix migration to asciidoctor tabs 2023-05-09 12:15:43 +01:00