Implementing a Java testing framework from scratch without reflection

By: Lorenzo Bettini

Abstract

Java reflection allows a program to inspect and manipulate program structure at run time and is a powerful mechanism used in many Java frameworks, including testing frameworks such as JUnit. However, reflection shifts key checks from compile time to run time and can introduce runner-level overhead; therefore, it is often desirable to avoid it when comparable functionality can be achieved with ordinary, statically checked mechanisms. In this paper, we present JNRTEST (Java no reflection Test), a Java testing framework built from scratch that avoids reflection, runtime annotations, and dynamic class loading. Instead, JNRTEST relies on object-oriented and functional programming mechanisms provided by modern Java: tests and lifecycle hooks are registered through explicit, typed APIs and executed directly by the runner, while integrations are implemented via an event-driven listener model. Overall, JNRTEST serves as a proof of concept that a practical Java testing framework can be built around a reflection-free core using ordinary, statically checked language mechanisms.

Keywords

Java, Reflection, Testing Framework

Cite as:

Lorenzo Bettini, “Implementing a Java testing framework from scratch without reflection”, Journal of Object Technology, Volume 25, no. 2 ( 2026), pp. 2:37-65, doi:10.5381/jot.2026.25.2.a2.

PDF | DOI | BiBTeX | Tweet this | Post to CiteULike | Share on LinkedIn