Trying to Unit Test an Object

First, sorry for the long reply time - I was on vacation.

Second - unless the value of the constant is inlined during compilation, you can change it via reflection at the beginning of the test method.

While I don’y have an example on how to do it in a test (or in Kotlin), here’s how I used Java reflection to change options list (private static final if I recall correctly) in a H2 console in Spring Boot: https://gist.github.com/Forinil/b79d7a9ed122d2b26cfb9e310094eaa0

1 Like