Background:
My goal is to collect various timestamps while executing JUnit 5 tests in a Spring environment to create a statistic of the durations of the different tasks. (Repository for reference)
Because I can't touch the actual test code, I have to register callbacks like the ContextRefreshedEvent from within my JUnit Jupiter extension. Currently I am registering these callbacks in a Spring configuration object and hope that this is found by some component scan in the test application. As you can imagine this does not work reliably for every test context.
Problem:
I hope that I can somehow register these events like the ContextRefreshedEvent manually in my first callback method from JUnit. As far as I understand, this requires me to add either a Configuration or a Component containing the callbacks to the currently running Spring Context at runtime.
Is that possible or do you know any other solution to my initial problem? I would really appreciate any input you have on this issue because I am working on this for quite a while now.
Thank you very much in advance!