Description
By default, the Maven Failsafe plugin relies on a set of file name patterns to determine which test classes to include. This is the <includes>
option, and its default values are
**/IT*.java
**/*IT.java
**/*ITCase.java
In v2.36.0, the IdentifierName
check (which I'm unreasonably excited about!) accurately detects those names as being in violation.
Unfortunately, for a user wishing to take advantage of Failsafe, working around this is a bit cumbersome; it seems they can...
- ... not run Error Prone on test code at all, but I would like to.
- ... change
<includes>
to any compliant non-default value, but that introduces non-standard behaviour for dubious reasons. - ... use
-XepOpt:IdentifierName:AllowInitialismsInTypeName=true
, but actually, that allows a name likeXMLHTTPRequest
that is specifically called out as in violation, and incidentally, is exactly the sort of situations I see people struggle with the most. - ... suppress each violation, which I personally consider the correct response but a noisy and tiresome one.
Every option is possible but all of them carry friction.
The behaviour I would most like to see is that IdentifierName
automagically did not flag these cases so the defaults Just Work™. But Error Prone cannot know which arbitrary patterns I might have set in my own <includes>
, so any support for this is bound to be either inflexible or complex. Correspondingly, I would suggest that IdentifierName
should at most allow Failsafe's default <includes>
values
A more flexible approach is a new option, -XepOpt:IdentifierName:MyBikeshed=*IT,*MXBean
, which passes a set of patterns to IdentifierName
to allow.
See also #4776.
$ ./mvnw clean test-compile -DepFlags='-XepDisableAllChecks -Xep:IdentifierName:ERROR'
[INFO] Scanning for projects...
[INFO]
...
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /.../src/test/java/example/ITFoo.java:[1,8] [IdentifierName] Classes should be named in UpperCamelCase, with acronyms treated as words (https://google.github.io/styleguide/javaguide.html#s5.3-camel-case); did you mean 'ItFoo'?
(see https://google.github.io/styleguide/javaguide.html#s5.2-specific-identifier-names)
[ERROR] /.../src/test/java/example/FooIT.java:[3,8] [IdentifierName] Classes should be named in UpperCamelCase, with acronyms treated as words (https://google.github.io/styleguide/javaguide.html#s5.3-camel-case); did you mean 'FooIt'?
(see https://google.github.io/styleguide/javaguide.html#s5.2-specific-identifier-names)
[ERROR] /.../src/test/java/example/FooITCase.java:[3,8] [IdentifierName] Classes should be named in UpperCamelCase, with acronyms treated as words (https://google.github.io/styleguide/javaguide.html#s5.3-camel-case); did you mean 'FooItCase'?
(see https://google.github.io/styleguide/javaguide.html#s5.2-specific-identifier-names)