You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TestNG has never required that @Test methods be public. Furthermore, the upcoming JUnit 5 also no longer requires that test methods be public.
The Spring TestContext Framework (TCF) should therefore also not require that test methods are public.
Analysis
The TCF in fact does not require that test methods are public, since this is the responsibility of the underlying testing framework (e.g., JUnit or TestNG); however, it is currently not possible to have a @Transactional test method be non-public. The reason is that AnnotationTransactionAttributeSource is by default configured to ignore non-public methods.
Deliverables
Ensure that @Transactional test methods are not required to be public
Prior to this commit, the TransactionalTestExecutionListener required @Transactional test methods to be public; however, neither TestNG nor
JUnit 5 require that @Test methods are public. Consequently, non-public
transactional test methods silently run without a transaction.
This commit removes the 'public' restriction on transactional test
methods by setting the 'publicMethodsOnly' flag in
AnnotationTransactionAttributeSource to false.
Sam Brannen opened SPR-14000 and commented
Overview
TestNG has never required that
@Test
methods bepublic
. Furthermore, the upcoming JUnit 5 also no longer requires that test methods be public.The Spring TestContext Framework (TCF) should therefore also not require that test methods are public.
Analysis
The TCF in fact does not require that test methods are public, since this is the responsibility of the underlying testing framework (e.g., JUnit or TestNG); however, it is currently not possible to have a
@Transactional
test method be non-public. The reason is thatAnnotationTransactionAttributeSource
is by default configured to ignore non-public methods.Deliverables
@Transactional
test methods are not required to bepublic
Affects: 3.2.16
Issue Links:
@BeforeTransaction
and AfterTransaction on non-public methodsReferenced from: commits df7b24b
The text was updated successfully, but these errors were encountered: