Skip to content

Bug,Regression: Duplicated calls to TestRunnerAdaptor before(...) and after(...) with Junit5 introduce problems in extensionsย #745

@TheOnlyAl

Description

@TheOnlyAl

Overview

I'm upgrading our projects from Arquillian 1.8.0.Final to 1.10.0.Final. During this process, most of our integration tests using Junit5, the arquillian-extension-persistence and arquillian-extension-transaction have started failing. I'm seeing errors related to duplicate keys and transaction issues.

My investigation points to a change in PR #583 as the likely cause.

Problem

The change in PR #583 appears to cause a duplicated invocation of TestRunnerAdaptor.before(...) and TestRunnerAdaptor.after(...), which in turn fires the Before and After events twice. It seems that extensions, such as the persistence and transaction extensions, were built on the assumption that these events would only be fired once.

For the persistence extension, this double-event firing causes problems. For example, when a test method has a @BeforeEach annotation and uses @SeedDataUsing(...), the internal dataset ends up containing duplicate data because the initial dataset is added twice. This leads to duplicate key errors.

For the transaction extension, a JTA transaction is started twice for the same test method. The extension then attempts to close the transaction on the first After event, and the second close call fails because the transaction is already closed, leading to a transaction exception.

It's likely that other extensions may also be affected by this behavior.

Solution?

I'm not certain if the correct solution is to fix the extensions or remove the duplicate calls. However, my best guess is to remove the duplicate calls, as test frameworks like TestNG and JUnit 4 seem to only call these methods once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions