jayway/powermock — pull request #6 by kaipe (2014-11-08 08:24:26+00:00)
Title: Improved JUnit integration with PowerMockRunnerDelegate annotation

PowerMockRunner of PowerMock-1.5.x achieves JUnit-integration by delegating to one of its PowerMockJUnit4[479]RunnerDelegateImpl, which fulfills its duties by reproducing the core JUnit functionality.

This pull-request opens a way for PowerMockRunner to concentrate on PowerMock-features (static-mocking etc) and leave the actual test-execution to JUnit's default runner (or another runner of your choice). This allows PowerMock to (without any modifications) support future new JUnit-features from day one! - And from there it was only a small step to make PowerMockRunner support delegation to any other runner-implementation, which can be specified by the new feature annotation "PowerMockRunnerDelegate".

In short there are two benefits:

1) Faster progress for PowerMock development as new JUnit features can be supported with no development effort.

2) PowerMock users can have PowerMockRunner delegate test-execution to a runner of their choice. The pull-request include example tests on delegation to "SpringJUnit4ClassRunner", "Parameterized", "Enclosed" and a "selfie"-runner.

I know that 2 can also be achieved by using PowerMockRule but @PowerMockRunnerDelagate has one obvious advantage: - Delegation can be made to a 3rd-party runner that does not support rules, whereas PowerMockRule can never work with a runner that does not have rule-support.
Also - AFAIK PowerMockRule supports almost all PowerMock features but there are not so many tests in the project code-base. The delegation solution in this pull-request can be activated with the system-property "powermock.implicitDelegateAnnotation=true", which is set by the new build-profile "implicitDelegateAnnotation" (in the root pom.xml). Therewith it is easily tested by running the old existing tests with the "implicitDelegateAnnotation" profile, whereas PowerMockRule needs separate test-classes.

I hope you like this pull-request and have it included in PowerMock's next feature release.