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

Allow @Parameters(source = SomeClass.class) to have non-static provide* methods #154

Open
kuporific opened this issue Apr 11, 2018 · 0 comments

Comments

@kuporific
Copy link

kuporific commented Apr 11, 2018

My use-case is to have an interface that defines methods that provide test parameters so that I can better enforce parameter sets that need to run against multiple tests.

Example:

public class MyClassTest {
  public interface MyParameters {
    Object[] provideParamSet1();
    Object[] provideParamSet2();
  }

  @Test
  @Parameters(source = MyTest1Params.class)
  public test1(String given, String expected) {
    ...
  }

  public static class MyTest1Params implements MyParameters {
    @Override public Object[] provideParamSet1() { ... }
    @Override public Object[] provideParamSet2() { ... }
  }


  @Test
  @Parameters(source = MyTest2Params.class)
  public test2(String given, String expected) {
    ...
  }

  public static class MyTest2Params implements MyParameters {
    @Override public Object[] provideParamSet1() { ... }
    @Override public Object[] provideParamSet2() { ... }
  }
}

(This would technically break backwards compatibility as I imagine the implementation of this feature would require a default constructor for the Parameters.source classes.)

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

No branches or pull requests

1 participant