On Wed, Jun 30, 2021 at 10:40 AM Ullrich Hafner <[email protected]> wrote:
> You can stub classes with Mockito as well > Beware mocking frameworks like Mockito and Powermock. They can cause failures which are terribly hard to debug; and tests can fail when some dependencies are updated even when the update is fully compatible from an API perspective, merely because some method deep in the call stack began calling something new which you did not mock yet. I would advise against their use. True unit tests should not require any special DI or mocking framework if you arrange code with this purpose in mind. Most Jenkins tests however use `JenkinsRule` to actually run code in a realistic context—takes ~5s to run a test case but gives reasonable confidence that the tested code path actually matches production. Often `@TestExtension` is used to add special extensions active only in a particular test case (note that this is distinct from DI since you are *adding* extensions to a pool, though it is possible to *override* a singleton extension called via `ExtensionList.lookupSingleton` using the `ordinal` attribute). Some plugins also use WireMock to let `JenkinsRule`-based tests interact with a mock version of an external service. -- 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/CANfRfr3MXyuQhayQRTJuj75ACUbT-N5LJ29rvU01Sc9%3D7CF6og%40mail.gmail.com.
