-
Notifications
You must be signed in to change notification settings - Fork 304
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
Rules shared between tests have ambiguous names #452
Comments
Running our CircleCI build again, we noticed that the JUnit test report is divided into test classes with one file per class. Every "project" that runs our |
Experimentally, we created a variant of the We did this by extending the |
run the following command > ./gradlew :archunit-example:example-junit4:test --tests "*.ServiceRulesTest" -P example Inspect the test result file at > archunit-example/example-junit4/build/reports/tests/test/index.html You will find a duplicated report for one of the projects, and the failure of the other project is lost. Issue: TNG#452 Signed-off-by: Christian Semrau <[email protected]>
…ad as belonging to the class that declared the rule Resolves TNG#452 Signed-off-by: Christian Semrau <[email protected]>
…stead as belonging to the class that declared the rule Resolves TNG#452 Signed-off-by: Christian Semrau <[email protected]>
run the following command > ./gradlew :archunit-example:example-junit4:test --tests "*.ServiceRulesTest" -P example Inspect the test result file at > archunit-example/example-junit4/build/reports/tests/test/index.html You will find a duplicated report for one of the projects, and the failure of the other project is lost. Issue: TNG#452 Signed-off-by: Christian Semrau <[email protected]>
…o longer as belonging to the class that declared the rule Resolves TNG#452 Signed-off-by: Christian Semrau <[email protected]>
Usually I would expect the report folders of different Gradle projects to be separate 🤔 Maybe that is why this problem hasn't popped up earlier. This might be something specific of your CI setup? But in any case, since the description contains both the test class that includes the rules as well as the rules class itself (in a hierarchical form), it would probably make sense to reflect this in the file name 🤔 Just that this seems like a build tool dependent convention. I'll try to look into your PR, why the tests break, as soon as I can find some time! And see if that is a general way that works for Gradle, Maven, IDEs, ... (where "general" is always very hard to say upfront 😉) |
Sorry, somehow I completely dropped the ball on this, since there was no further reaction and nobody every reported the problem again 🙈 But somehow I stumbled over this ancient issue again today and decided to look into it again. I think we should always use the outermost class as the test location, but I wanted to somehow avoid confusion by not making the test look like it really is declared in that class then (e.g. I don't want the test report exactly as if it comes from a field |
…on (#1279) So far, if we include rules from other test classes, e.g. ``` @AnalyzeClasses(..) class ExampleTest { @archtest static final ArchTests nested = ArchTests.in(Other.class); } ``` then the nested class (`Other.class` in this case) will be used as test location. This can cause confusion, because by this if `Other.class` is included in two separate test classes, analyzing different locations via `@AnalyzeClasses`, the results will be reported for the same test class `Other.class`. We now report the outermost class that started the test (the one with `@AnalyzeClasses) as the test location for both JUnit 4 and JUnit 5. To make it easy to understand through which path a rule is included in more complex scenarios, we extend the display name to include the path of nested classes. Resolves: #452
Thank you for resurrecting this issue! 🙏 |
Glad to hear that it's still gonna be useful 🙂 |
We just updated to ArchUnit 1.3.x and finally removed our custom runner. I really like the path-like test names that are generated by default now. In the GH action report, they are presented to me like this: |
As mentioned in my other post #450, we have lots of "projects" that share a "platform", and we are restricting access to the "platform".
The "platform" provides some rules annotated as
@ArchTest
, e.g. "only_use_allowed_platform_classes
" in a class "platform.ApiUsageRules
". Each "project" declares a JUnit 4 test "projectX.ApiUsageTest
", annotated to run theArchUnitRunner
, which tests the rules declared inApiUsageRules
viaArchRules
.Several "projects" are built together with Gradle on CircleCI. When one of the rules fails, the failing test is called "
only_use_allowed_platform_classes - platform.ApiUsageRules
", which the location where the rule was defined. That is of course the same for all "projects".Most of the time, I could deduce from the violations which "project" is affected, but not always. From the build test output I could not see which test failed either.
Do you have suggestions how I can more easily find the actual test that failed?
Is this a problem due to our build setup, i.e. would I find the actual test class in the output or test artifacts of a simple/standard Gradle/Maven build?
I thought about adding the actual test class name ("
projectX.ApiUsageTest
") to the test name.Kind regards,
Christian
The text was updated successfully, but these errors were encountered: