Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation check that @ClassRule can only return an implementation of TestRule #1019

Closed
npathai opened this issue Nov 2, 2014 · 1 comment · Fixed by #1020
Closed
Milestone

Comments

@npathai
Copy link
Contributor

npathai commented Nov 2, 2014

Presently @ClassRule can be an implementation of TestRule or MethodRule but it does not make sense to allow MethodRule. So as per discussion on #1016 with @kcooney creating this issue.

// should fail validation as @ClassRule should only allow implementation of `TestRule` but passes
    public class ClassRuleTest {
        @ClassRule
        public static MethodRule methodRule() {
            return new MethodRule() {

                @Override
                public Statement apply(Statement base, FrameworkMethod method, Object target) {
                    return base;
                }
            };
        }

        @Test
        public void doNothing() {

        }
    }
@npathai
Copy link
Contributor Author

npathai commented Nov 2, 2014

@kcooney I am working on it. Adding separate validation in CLASS_RULE_VALIDATOR and CLASS_RULE_VALIDATOR to only allow TestRule.

npathai added a commit to npathai/junit that referenced this issue Nov 2, 2014
npathai added a commit to npathai/junit that referenced this issue Nov 2, 2014
npathai added a commit to npathai/junit that referenced this issue Nov 2, 2014
@marcphilipp marcphilipp added this to the 4.13 milestone Nov 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants