Skip to content

Create MatchXpath instance to forbig usage of 'expected' element in Test annotation of junit #9137

@romani

Description

@romani

code like:

public class MyObjTest {

    @Test(expected = IllegalArgumentException.class) // violation should be there
    public void getNameWithNullValue() {
        MyObj obj = new MyObj();
        myObj.setName(null);
    }
}

update

<module name="MatchXpath">
<property name="query" value="//CLASS_DEF[@text!='Checker' and @text!='Main']
//LITERAL_CATCH//METHOD_CALL[.//IDENT[@text = 'printStackTrace']]/.."/>
<message key="matchxpath.match" value="Avoid using 'printStackTrace'."/>
</module>

to find expected element in code instead of search of printstacktrace in code as it is duplicate of other valiidations.
We need to add this config to our javadoc/xdoc/html.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions