Reflection Test Helper

Private-method reflection for tests

A Java helper for tests that have to reach a private method or field. from takes the class under test, addArgument its parameters, and invokeMethod calls the method by name.

ArchivedPersonalOpen source

Record

Kind
Package
Role
Author
Started
March 2021
Ended
March 2021
Licence
Apache-2.0

Technology1

Evidence11 sources

The GitHub repository is archivedrepogithub.com The LICENSE file is the unmodified text of the Apache License 2.0licencegithub.com ReflectionTestHelper.from takes the class under test and builds an instance of it through its declared no-argument constructor, made accessible by reflection, so the test never writes that itself; its two type parameters name the class under test and the return type of the method to be invokedsourcegithub.com The whole surface is five methods — from, setFieldValue, getFieldValue, addArgument and invokeMethod — of which setFieldValue and addArgument return the helper, so the fields and the arguments are set by chained calls before the invocationsourcegithub.com ReflectionMethod, which is package-private, resolves the method by its name and by the argument types collected through addArgument, and rethrows every checked reflection failure as an IllegalStateException; an empty method name is an IllegalArgumentExceptionsourcegithub.com ReflectionField, also package-private, reaches a field through getDeclaredField and setAccessible and rethrows the same failures as an IllegalStateException, which is what lets a test set up state the class does not exposesourcegithub.com The published javadoc documents a single class, ReflectionTestHelperdocsmyconsciousness.github.io app/build.gradle sets the group org.thinkit.test.util, declares Guava, Apache Commons Lang, Lombok and JUnit 5 and no org.thinkit coordinate, and publishes to GitHub Packages rather than to a public repositorysourcegithub.com Three releases were published, v1.0.2 on 8 March 2021, v1.0.4 on 13 March 2021 and v1.0.5 on 14 March 2021repogithub.com The whole history is eleven days — the first commit is 3 March 2021 and the last is 14 March 2021, which is also the v1.0.5 tag and the head of mainrepogithub.com The README states the copyright as Kato Shinya, 2021, and its install section directs the reader to contact the author for a token to download the packagedocsgithub.com

Links3

Relations1 edge

Zenna DBUsed byAnnotation-driven JSON content mapping