GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Surefire issue with archunit-tests · Issue #839 · apache/maven-surefire

Surefire issue with archunit-tests #839

New issue
Copy link
New issue
Copy link
Closed
#828
Closed
Surefire issue with archunit-tests#839
#828
Copy link
Labels
bugSomething isn't working
Milestone
3.5.4

Description

@goll-michael
goll-michael
opened on Apr 30, 2025
Issue body actions

Affected version

3.5.3

Bug description

ArchUnit tests are not executed correctly with Surefire 3.5.3.

For an underlying DTO class

package custom;
public class MyDTO {
    private String param;
    public String getParam() {
        return param;
    }
    public void setParam(String param) {
        this.param = param;
    }
}

the following ArchUnit test is defined

package custom;

import com.tngtech.archunit.core.importer.ImportOption;
import com.tngtech.archunit.junit.AnalyzeClasses;
import com.tngtech.archunit.junit.ArchTest;
import com.tngtech.archunit.lang.ArchRule;
import com.tngtech.archunit.lang.syntax.ArchRuleDefinition;

@AnalyzeClasses(packages = "custom", importOptions = ImportOption.DoNotIncludeTests.class)
public class ArchUnitTest {

    @ArchTest
    public static final ArchRule DTO_IN_PACKAGE_DTO= ArchRuleDefinition.classes()
            .that().haveSimpleNameEndingWith("DTO")
            .should().resideInAPackage("..dto..");
}

The pom.xml looks like this:

<?xml version="1.0"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0">
    <modelVersion>4.0.0</modelVersion>

    <groupId>custom</groupId>
    <artifactId>surefire-test</artifactId>
    <version>0.0.1</version>

    <dependencies>
        <dependency>
            <groupId>com.tngtech.archunit</groupId>
            <artifactId>archunit</artifactId>
            <version>1.4.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.tngtech.archunit</groupId>
            <artifactId>archunit-junit5</artifactId>
            <version>1.4.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.5.3</version>
            </plugin>
        </plugins>
    </build>

</project>

When running mvn clean test, the following output is generated (excerpt):

[INFO] --- surefire:3.5.3:test (default-test) @ surefire-test ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running custom.ArchUnitTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.651 s -- in custom.ArchUnitTest
[INFO] 
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

The assumption would be that the test fails, which is the case with version 3.5.2

[INFO] --- surefire:3.5.2:test (default-test) @ surefire-test ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running custom.ArchUnitTest
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.638 s <<< FAILURE! -- in custom.ArchUnitTest
[ERROR] ArchUnitTest.DTO_IN_PACKAGE_DTO -- Time elapsed: 0.628 s <<< FAILURE!
java.lang.AssertionError:
Architecture Violation [Priority: MEDIUM] - Rule 'classes that have simple name ending with 'DTO' should reside in a package '..dto..'' was violated (1 times):
Class <custom.MyDTO> does not reside in a package '..dto..' in (MyDTO.java:0)
        at com.tngtech.archunit.lang.ArchRule$Assertions.assertNoViolation(ArchRule.java:94)
        at com.tngtech.archunit.lang.ArchRule$Assertions.check(ArchRule.java:86)
        at com.tngtech.archunit.lang.ArchRule$Factory$SimpleArchRule.check(ArchRule.java:165)
        at com.tngtech.archunit.lang.syntax.ObjectsShouldInternal.check(ObjectsShouldInternal.java:81)
        at com.tngtech.archunit.junit.internal.ArchUnitTestDescriptor$ArchUnitRuleDescriptor.execute(ArchUnitTestDescriptor.java:168)
        at com.tngtech.archunit.junit.internal.ArchUnitTestDescriptor$ArchUnitRuleDescriptor.execute(ArchUnitTestDescriptor.java:151)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

[INFO] 
[INFO] Results:
[INFO]
[ERROR] Failures: 
[ERROR]   Architecture Violation [Priority: MEDIUM] - Rule 'classes that have simple name ending with 'DTO' should reside in a package '..dto..'' was violated (1 times):
Class <custom.MyDTO> does not reside in a package '..dto..' in (MyDTO.java:0)
[INFO]
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
Reacted by Kai Zander, Henning Meltz, S. Bonzelet, AccsonautHristo, Marcus Voltolim and Simone Conte

Activity

  1. goll-michael
    added
    bugSomething isn't working
    on Apr 30, 2025
  2. marcusvoltolim commented on Aug 20, 2025

    @marcusvoltolim
    marcusvoltolim
    on Aug 20, 2025
    More actions

    Same issue here! I fixed version 3.5.2

  3. olamy
    added a commit that references this issue on Sep 3, 2025

    Add test from apache#839

    329c90d
  4. olamy commented on Sep 3, 2025

    @olamy
    olamy
    on Sep 3, 2025
    Member
    More actions

    thanks a lot your test has been added as part of #828

  5. olamy
    linked a pull request that will close this issue[SUREFIRE-2298] fix xml output with junit 5 nested classes (fix integration with Cucumber and Archunit) #828on Sep 4, 2025
  6. olamy
    added this to the 3.5.4 milestone on Sep 4, 2025
  7. olamy
    closed this as completedin #828on Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      • 3.5.4

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.