-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maven ignores tests defined as ArchTest fields #1157
Comments
Thanks for raising the issue! I couldn't exactly reproduce your problem, but saw that ArchUnit 1.1.0 is not fully compatible with JUnit 5.10, so I assume that your issue is related to that. This examplegit clone https://github.com/TNG/ArchUnit-Examples.git
cd ArchUnit-Examples/example-junit5
cat > pom.xml << EOF
<?xml version="1.0"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.tngtech.archunit</groupId>
<artifactId>example-junit5</artifactId>
<version>1.1.0</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit5</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
<!-- These are the 'production' dependencies of the Demo src/main/java files -> just for Demo purposes, otherwise irrelevant -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-ejb_3.1_spec</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.2.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
</plugin>
</plugins>
</build>
</project>
EOF
mvn test fails with
– which can be resolved by downgrading |
The new `getAncestors()` method in `TestDescriptor` (https://junit.org/junit5/docs/5.10.0/release-notes/) is obviously not available in ``` com.tngtech.archunit.junit.internal.AbstractArchUnitTestDescriptor extends org.junit.platform.engine.support.descriptor.AbstractTestDescriptor ``` from `org.junit.platform:junit-platform-engine:1.9.x`. Solves #1157 Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
The new `getAncestors()` method in `TestDescriptor` (https://junit.org/junit5/docs/5.10.0/release-notes/) was obviously not available in ``` com.tngtech.archunit.junit.internal.AbstractArchUnitTestDescriptor extends org.junit.platform.engine.support.descriptor.AbstractTestDescriptor ``` from `org.junit.platform:junit-platform-engine:1.9.x`. Solves #1157 Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
The issue of my example above can also be solved by explicitly adding the new <dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-engine</artifactId>
<version>1.10.0</version>
<scope>test</scope>
</dependency> @Scaronthesky, does this help in your case, too? |
Hmm, I don't know what changed between last week and now, but I can't seem to reproduce this issue anymore. It works even without adding the aformentioned "org.junit.platform:junit-platform-engine" dependency. Maybe some one else is suffering from the same problem in the future. For what it's worth I ran into the same issue as you while trying to create a minimum working example. After adding the "org.junit.platform:junit-platform-engine" dependency the tests can be run and both tests (field and method) are executed. Thanks for your support. |
The new `getAncestors()` method in `TestDescriptor` (https://junit.org/junit5/docs/5.10.0/release-notes/) was obviously not available in ``` com.tngtech.archunit.junit.internal.AbstractArchUnitTestDescriptor extends org.junit.platform.engine.support.descriptor.AbstractTestDescriptor ``` from `org.junit.platform:junit-platform-engine:1.9.x`. Solves #1157 Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
I'm under the impression that Maven seems to ignore ArchUnit tests which are defined as fields with the @archtest annotation.
I copied some of the CodingRulesTest from the ArchUnit-Examples project, e. g. "No Access to Standard streams". These tests work fine when I execute them with IntelliJ. Maven completely ignores them, though. Maven executes only tests which are defined as "proper" test methods.
Is this a configuration issue or a bug? I had a look at the documentation and issues but could not find anything.
In the examples project the ArchRule fields are private. I made the public but it makes no difference. They are still ignored.
maven-surefire-plugin:3.1.2
Using configured provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
com.tngtech.archunit:archunit-junit5-api:1.1.0
com.tngtech.archunit:archunit-junit5-engine:1.1.0
org.junit.jupiter:junit-jupiter-api:5.10.0
The text was updated successfully, but these errors were encountered: