ArchUnit icon indicating copy to clipboard operation
ArchUnit copied to clipboard

ArchTest on fields does not run under Maven Surefire Plugin 3.5.3+

Open erwanosouf opened this issue 10 months ago • 6 comments

There is a bug when running ArchUnit test using ArchTest on a ArchRule field.

It works under Maven Surefire Plugin 3.5.2 but not 3.5.3

Note that ArchTest set on methods work.

I have created a repo demonstrating the issue. Refer to the Readme for reproduction instruction

Description This repository contains a Test Case to exhibit a behavior that appeared in Surefire 3.5.3.

A Junit5 Test Class ArchUnitSurefireBugTest contains 3 tests

thisTestUsingArchTestFieldShouldRun : A Test using @ ArchTest on a field thisTestUsingArchTestMethodShouldRun : A Test using @ ArchTest on a method thisStandardTestShouldRun : a standard JUnit Test using no ArchUnit syntactic sugar. Expected Run mvn test -Dsurefire.version=3.5.2 -f pom.xml

All tests run

Actual mvn test -Dsurefire.version=3.5.3 -f pom.xml

thisTestUsingArchTestFieldShouldRun does not run.

erwanosouf avatar Apr 03 '25 12:04 erwanosouf

Thank you @erwanosouf for figuring this out. Was going crazy over this!

leflamm avatar Apr 03 '25 12:04 leflamm

Is this a bug in surefire or in ArchUnit? I wonder if we should create a bug report in the surefire plugin as well? 3.5.3 is only a patch release that should not fail in such a way?

uhafner avatar Apr 07 '25 06:04 uhafner

I did a git bisect on the changes from surefire-3.5.2 to maven-surefire-3.5.3 and identified that commit 5aeca1971 for apache/maven-surefire#815 introduced the change.

hankem avatar Apr 08 '25 06:04 hankem

(FYI: The issue will be adressed by SUREFIRE-2298 / apache/maven-surefire#828.)

hankem avatar Apr 09 '25 06:04 hankem

We have the same behaviour with surefire and failsafe plugin in Version 3.5.3. But not only on ArchUnit-Tests but also on Cucumber-Tests like the following

@Suite(failIfNoTests = false)
@IncludeEngines("cucumber")
@SelectClasspathResource("....")
@ConfigurationParameter(key = Constants.GLUE_PROPERTY_NAME, value = "...")
@ConfigurationParameter(key = Constants.FILTER_TAGS_PROPERTY_NAME, value = "....")
@ConfigurationParameter(key = Constants.PLUGIN_PROPERTY_NAME, value = "...")
public class CucumberTest {
}

Eischer avatar May 28 '25 09:05 Eischer

i have same issues with cucumber and archunit

BegoMaier avatar Jun 12 '25 14:06 BegoMaier

Same issue here, anyone still working on archunit and is able to fix this?

royteeuwen avatar Sep 01 '25 08:09 royteeuwen

@royteeuwen work to fix this is currently happening in https://github.com/apache/maven-surefire/pull/828

StefanBauerTT avatar Sep 01 '25 08:09 StefanBauerTT

@royteeuwen, ArchUnit cannot prevent the Surefire bug. The workaround is to downgrade to Maven Surefire 3.5.2.

hankem avatar Sep 01 '25 13:09 hankem

The underlying issue seems to be fixed in Surefire 3.5.4 (my local test worked again) https://github.com/apache/maven-surefire/issues/2601

MoellJ avatar Sep 15 '25 15:09 MoellJ

Confirmed locally that the bug is fixed. I updated the repository to reflect that and I will archive it.

Closing the issue.

erwanosouf avatar Sep 15 '25 20:09 erwanosouf