Skip to content

JUnit5 container does not work well with Arquillian transaction extension #31

@bartoszmajsak

Description

@bartoszmajsak

@tosix1988 commented on Wed Mar 10 2021

Hello,

we have been recently migrating out arquillian tests from JUnit4 container to JUnit5 container, and it mostly went without issues. However, we have spotted that the arquillian JTA extension has some issues with JUnit5 container.

Simply put, it seems that if the test is annotated with Transactional(value = TransactionMode.COMMIT), the test transaction is still rolled back (with JUnit4 this works as expected). I wasn't able to find much during debugging, but I have noticed the following:

  • in org.jboss.arquillian.transaction.impl.lifecycle.TransactionHandler, the testRequiresRollbackDueToFailure method always returns true, because testResultInstance.get() is always null. The TestContext is active at that point, but it stores no TestResult instance (even though the test passed). On JUnit4, the TestResult instance is present, and the testRequiresRollbackDueToFailure returns correct result.
  • with JUnit4 container, both ClientTestExecuter and ContainerTestExecuter are invoked; with JUnit 5, only ClientTestExecuter gets invoked (I am not sure if this makes any difference).

I don't know if this is the proper place to file this bug, or whether the arquillian-extension-transaction project would be a better place.

To ease investigation, I have attached two sample projects that should help with reproducing the issue.
transactional-junit4.zip
transactional-junit5.zip

OS details:

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\programs\apache-maven-3.6.3
Java version: 1.8.0_282, vendor: AdoptOpenJDK, runtime: C:\Program Files\Java\jdk-8.0.282\jre
Default locale: sk_SK, platform encoding: Cp1250
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

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