KentBeck/junit — pull request #623 by pimterry (2013-01-28 23:08:27+00:00)
Title: Added validation that all datapoint methods and fields are public and static to theory initialization

This fixes #125. In that issue, tests with non-static or non-public datapoint methods are ignored because they're not checked for when constructing the instance, and when the values are retrieved for theory parameters in getValue() in MethodParameterValue (in AllMembersSupplier) an exception is thrown, but then swallowed in addMultiPointMethods/addSinglePointMethods in AllMembersSupplier.

There's another abandoned pull request trying fixing this in #328, which rethrows all exceptions thrown in datapoint methods, including this one. This is arguably dubious since you could potentially have other exceptions coming from datapoint methods, and it's not clear whether those should actually fail tests. This commit does not affect issue 137 (caused by the exception hiding), which #328 does try to solve.

On the other hand, datapoint methods that are definitely being entirely ignored are a legitimately incorrect use of the datapoints annotation, and that should actually fail, I think.

While there was no error before this for non-static datapoint methods, there was an initialization error for non-static/non-public `@DataPoint` fields. There wasn't an error for `@DataPoints` array fields though, for no possible good reason I can see, since this doesn't have any of the same exception hiding issues as the methods do.

With this commit all of the above is fixed, by adding checks on test initialization that look at all the datapoint methods and fields, and confirms that they're public and static. This already existed for fields annotated with `@DataPoint`, but now also covers array fields annotated with `@DataPoints` and array and singleton annotated datapoint methods.