arch-unit-maven-plugin icon indicating copy to clipboard operation
arch-unit-maven-plugin copied to clipboard

Import classes from Main and Test scope

Open CarlosHeinz opened this issue 1 year ago • 0 comments

Summary

Some test scenarios rely on Main and Test classes as well. Is there a way to configure the scope for both? I guess no, because documentation says <!-- scope can be "main" or "test" -->

Type of Issue

It is a :

  • [ ] bug
  • [x] request
  • [ ] question regarding the documentation

Motivation

For example have a look on this rule from GeneralCodingRules https://github.com/TNG/ArchUnit/blob/43fe9e28f01ba0c781f56fed75977e62251f08e5/archunit/src/main/java/com/tngtech/archunit/library/GeneralCodingRules.java#L434C33-L434C33

It requires Main and Test classes loaded together to compare them and tell if there is a violation.

I can't get this Rule running as intended with this Plugin. However, if i run the Rule as JUnit Test without the Plugin and import Main and Test classes, it works as expected:

@Test
public void testClassesShouldResideInTheSamePackageAsImplementation() {
    JavaClasses myClasses = new ClassFileImporter().importPaths("target/classes", "target/test-classes");
    com.tngtech.archunit.library.GeneralCodingRules.testClassesShouldResideInTheSamePackageAsImplementation().check(myClasses);
}

Current Behavior

Expected Behavior

Steps to Reproduce (for bugs)

Your Environment

  • Version used:
  • OS and version:
  • Version of libs used:

CarlosHeinz avatar Aug 04 '23 08:08 CarlosHeinz