TNG / ArchUnit

A Java architecture test library, to specify and assert architecture rules in plain Java
http://archunit.org
Apache License 2.0
3.23k stars 298 forks source link

No hyperlinks if whole class violates a rule #61

Closed uhafner closed 6 years ago

uhafner commented 6 years ago

The following rule produces an assertion error (in IntelliJ) that contains only text, no hyperlinks to the classes.

    /**
     * Test classes should not be public (Junit 5).
     */
    @Test
    void shouldNotUsePublicInTestCases() {
        JavaClasses classes = new ClassFileImporter().importPackages("edu.hm.hafner");

        ArchRule noPublicClasses = noClasses().that().haveSimpleNameEndingWith("Test")
                .should().bePublic();

        noPublicClasses.check(classes);
    }

Produces the output (example):

java.lang.AssertionError: Architecture Violation [Priority: MEDIUM] - Rule 'no classes that have simple name ending with 'Test' should be public' was violated (71 times):
class edu.hm.hafner.ArchitectureRulesTest has modifier PUBLIC
class edu.hm.hafner.analysis.AbstractParserTest has modifier PUBLIC
class edu.hm.hafner.analysis.IssueFilterTest has modifier PUBLIC
class edu.hm.hafner.analysis.IssueTest has modifier PUBLIC
class edu.hm.hafner.analysis.parser.AcuCobolParserTest has modifier PUBLIC
class edu.hm.hafner.analysis.parser.AjcParserTest has modifier PUBLIC
class edu.hm.hafner.analysis.parser.AnsibleLintTest has modifier PUBLIC
[...]

Expected result: each class has a hyperlink (as the other assertion errors from ArchUnit).

codecholeric commented 6 years ago

Yeah, I remember that I didn't include this back then, cause I wasn't sure, which line number to print. However, I guess (SomeClass.java:0) would be an alright link to just jump to the file... I'll add this with the next release (I think there are more places than this, where it would make sense to add the link, like assignable/implement, where I didn't include it either)