Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@npathai

Description

@npathai

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() {

        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions