-
@TestInstance(value = TestInstance.Lifecycle.PER_CLASS) public abstract class ReflectTestThe base class for reflection tests, which provides access to systems for runtime compilation, as well as extensions for easily accessing Core Reflection objects.
Types can be initialized in the class's constructor using sources, and these will be automatically compiled before any of the tests run. Each test method also receives a fresh value in sources, so they can configure local types. Note that these types know nothing about the types in the constructor, and that you must explicitly compile them before using them.
internal class SomeTest: ReflectTest() { val A by sources.add("A", "@rt(TYPE_USE) @interface A {}") val X by sources.add("X", "class X {}") val Generic by sources.add("Generic", "class Generic<T> {}") val types = sources.types { +"X[]" +"Generic<X>[]" +"@A X @A []" +"Generic<@A X>[]" block("K", "V") { +"K[]" +"@A Generic<V>" } } @Test fun `methods should not override themselves`() { val X by sources.add("X", "public class X { public void method() {} }") sources.compile() assertFalse(Mirror.reflect(X._m("method")).doesOverride(X._m("method"))) } }val sources = TestSources() val X: Class<*> by sources.add("X", "class X {}") val A: Class<Annotation> by sources.add("A", "@interface A {}") val types = sources.types { +"? extends X" block("T") { +"T" } } sources.compile() types["? extends X"] types["T"]
-
-
Constructor Summary
Constructors Constructor Description ReflectTest(String globalImports)
-
-
-
Constructor Detail
-
ReflectTest
ReflectTest(String globalImports)
-
-