Skip to content

@Transactional on test class ignored for test methods declared in superclass [SPR-7824] #12480

@spring-projects-issues

Description

@spring-projects-issues

Andrei Badea opened SPR-7824 and commented

Have the following test classes:

@ContextConfiguration(...)
public class MyTestBase extends AbstractTestNGSpringContextTests {

	protected boolean beforeTransaction;

	@Test
	public void test() {
		Assert.assertTrue(beforeTransaction);
	}
}
@TestExecutionListeners({ TransactionalTestExecutionListener.class })
@Transactional
public class MyTest extends MyTestBase {

	@BeforeTransaction
	public void before() {
		beforeTransaction = true;
	}
}

Run MyTest.java. The expectation is that the @Transactional annotation is handled and the test() method runs in a transaction. This does not happen. AbstractFallbackTransactionAttributeSource seems to have been written with interfaces in mind, where the "most specific method" is in the implementation class. So for the case above, one would expect the most specific method to be MyTest.test(), but it actually is MyTestBase.test(). I did not find a way to get a java.lang.reflect.Method handle for MyTest.test().


Affects: 3.0.4

Issue Links:

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulestatus: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions