Skip to content

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

Closed as not planned
@hgh1472

Description

@hgh1472

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

                // .. 
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by another

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions