Replies: 1 comment
|
Hi @sebersole No, JUnit Jupiter does not have an extension point equivalent to a Java agent's class-load transformation. JUnit extensions can participate in discovery/test lifecycle and invocation, but they do not receive class bytes before the JVM defines an arbitrary class. For true load-time enhancement, use the Java instrumentation API: public static void premain(String args, Instrumentation instrumentation) {
instrumentation.addTransformer(new MyClassFileTransformer());
}with the agent supplied using A There is also an important detail with an annotation such as: @DomainModel(annotatedClasses = {SomeClass.class, AnotherClass.class})If you discover those values from a JUnit extension, you are already dealing with If the agent needs to discover enhancement targets without loading them first, consider representing the targets as class names/metadata that the agent can match independently, rather than relying on a Jupiter extension to obtain the So the responsibilities should be separated:
Please mark this answer as accepted if it helped, thank you. |
Uh oh!
There was an error while loading. Please reload this page.
Is there an existing extension point in JUnit 5 that would allow me to hook into the loading of test related classes, Java agent style?
The classes to be enhanced are specified by extension annotations. E.g.
Here, I'd want
SomeClassandAnotherClassto be enhanced as they get loaded.All reactions