No, it’s not a bug in Gradle, you just don’t do what you think you do.
You are basically tripping over Groovy syntax. includes calls PatternFilterable.html#getIncludes and gives you the result which is a Set<String>. <anyCollection>[...] calls Collection#getAt from the GDK.
This method returns a list of the values of the property with the given name on each of the collections elements.
In your case includes is empty and so the getAt also just returns an empty list and you effectively did nothing.
If you would have any include already present, for example by doing
include 'foo'
includes['baz']
it would try to get the property baz on the String foo and fail with a MissingPropertyException.
What you probably intended to do is includes = ['**/test/**/*.java'].
Issues like this are the reason I strongly recommend to use the Kotlin DSL instead. You immediately get type-safe build scripts, much better error messages if you mess up the syntax, and amazingly better IDE support, if you use a proper IDE like IntelliJ.