Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow non-public @Transactional test methods [SPR-14000] #18573

Closed
spring-projects-issues opened this issue Feb 29, 2016 · 1 comment
Closed
Assignees
Labels
in: test Issues in the test module type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Feb 29, 2016

Sam Brannen opened SPR-14000 and commented

Overview

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

  1. Ensure that @Transactional test methods are not required to be public

Affects: 3.2.16

Issue Links:

Referenced from: commits df7b24b

@spring-projects-issues
Copy link
Collaborator Author

Sam Brannen commented

Completed as described in GitHub commit df7b24b:

Allow non-public @Transactional test methods

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants