Skip to content

Duplicate given setup in @beforeEach and test methods in JpaTransactionManagerTests #34804

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

Closed
hgh1472 opened this issue Apr 23, 2025 · 1 comment
Labels
status: superseded An issue that has been superseded by another

Comments

@hgh1472
Copy link
Contributor

hgh1472 commented Apr 23, 2025

I've noticed that some given setup logic in the @BeforeEach method is also repeated in several individual test methods in the JpaTransactionManagerTests.

Is there a specific reason for this duplication?

If not, is it okay if i remove duplicated setup in test methods?

for example

class JpaTransactionManagerTests {
        // ...

	@BeforeEach
	void setup() {
		given(factory.createEntityManager()).willReturn(manager);
		given(manager.getTransaction()).willReturn(tx);
		given(manager.isOpen()).willReturn(true);
	}

        @Test
	void testTransactionCommit() {
		given(manager.getTransaction()).willReturn(tx); // duplicated given setup

                // .. 
	}
@rstoyanchev
Copy link
Contributor

Superseded by #34807.

@rstoyanchev rstoyanchev closed this as not planned Won't fix, can't repro, duplicate, stale Jun 4, 2025
@rstoyanchev rstoyanchev added status: superseded An issue that has been superseded by another and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another
Projects
None yet
Development

No branches or pull requests

3 participants