How to change one system property without code or from command line
I'm developing a mocking framework and I need to change the class loader that unit uses to something else (This is due to a property of the API I'm mocking). I found that you can do this reliably in Junit by creating a custom LauncherInterceptor. The problem is that a system property needs to be assigned for this LauncherInterceptor implementation to be found.
I'm therefore wondering if it's possible to set a system property from a library that will later be used during tests for other projects. The user should preferably not have to do anything. Yes, there is the
System.setProperty
function, but this requires a class to be loaded for this to work, which might not reliably be the case.4 Replies
⌛
This post has been reserved for your question.
Hey @Thorinwasher! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
I'm not sure what's the real question, but the spi system was made so that libraries can ensure they run a little code just by being on the classpath without the library user having to load any class.
That seems like the most reasonable approach; to use the service provider interface. Is there a service I can register that will run before class loading of unit tests?
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.