Hi there, I have a question regarding unit testing a plugin which uses Guice. As per this old (?) documentation : https://wiki.jenkins.io/display/JENKINS/Dependency+Injection I implemented the dependency injection in my plugins. The thing is, if we take the example of the documentation, how can we test the `MyPublisher.java` class? Because it is directly calling the `Guice.createInjector` method with configured modules from within the class itself. I can indeed easily test the subsequent classes like `MySvc` but not the `MyPublisher` one.
I think I have two options there, but I don't know if there are maybe others: 1. There is something that I don't know about Guice which can let me substitute the modules loaded into Guice for mocked ones. 2. I'm suppose to rely on the `.inject(this)` mechanism and in my tests I use the `setMySvc` method to circumvent the call to `Guice.createInjector()` which will be made if I don't have a MySvc set. Is the second option the good one? Or is there some kind of other way of doing this that I'm not aware of? Best Regards, Martin -- <https://www.tuleap.org/fr/ebook-agilite-a-lechelle/?utm_source=signature-mail&utm_medium=martin-goyot&utm_campaign=banner-mail-promo-ebook-1> -- You received this message because you are subscribed to the Google Groups "Jenkins Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CA%2Bb6JB8onwFqVzWd6z0p5i_CjRdoQ_uFo5M-yTSov0AnWg48Dg%40mail.gmail.com.
