Thanks, this definitely would solve the problem, though it seems like a big 
refactor for a plugin I don't maintain.

I will ask the maintainers to see if this such a PR would be acceptable. 
Meanwhile, do you have any other thoughts? 

On Tuesday, November 10, 2020 at 10:40:26 PM UTC [email protected] wrote:

> It would be much simpler if you change the way you access the 
> PluginManager. I am using a Facade (
> https://github.com/jenkinsci/plugin-util-api-plugin/blob/master/src/main/java/io/jenkins/plugins/util/JenkinsFacade.java)
>  
> for all calls to the running Jenkins instance in my plugins. This facade 
> then can be replaced by a stub in your tests. 
>
> Example: 
> https://github.com/jenkinsci/warnings-ng-plugin/blob/master/plugin/src/test/java/io/jenkins/plugins/analysis/core/util/ModelValidationTest.java#L104
>
>
> Am 10.11.2020 um 19:39 schrieb Hosh <[email protected]>:
>
> Hi all,
>
> I'm trying to write some tests for some changes I made to the datadog 
> plugin at the request of the maintainer. The tests should ideally mock the 
> PluginManager that JenkinsRule uses as I'm trying to test that the code is 
> returning certain numbers based on what plugins are installed (e.g. active, 
> inactive, updatable plugins etc)..
>
> The problem however is that I am unable toset the plugin manager when 
> trying to mock it. I've tried using new 
> JenkinsRule().with(mock(PluginManager.class)), but this seemed to cause 
> issues in the rest of the code, setting the plugin manager in any other way 
> complains that the plugin manager is already set.
>
> For reference, the PR is located here: 
> https://github.com/jenkinsci/datadog-plugin/pull/156
>
> Thanks
>
> -- 
> 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/2415979d-575e-4033-8b37-fd6686bce140n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jenkinsci-dev/2415979d-575e-4033-8b37-fd6686bce140n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
>

-- 
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/e70cd019-8d10-4774-b88d-d12732003a93n%40googlegroups.com.

Reply via email to