Demos how parameterized test can be implemented using JUnit Rules without a custom TestRunner
Java
Switch branches/tags
Nothing to show
Latest commit d11d2f2 Feb 27, 2016 @schauder Merge pull request #3 from hennr/master
add some convenience for people giving this demo a try

README.md

Parameterized Tests With Rules

Demos how parameterized test can be implemented using JUnit Rules without a custom TestRunner.

You can define Generators for creating all the parameters to use for the the tests.

Inside the test you can access the current value of the parameter using the value() method of the rule.

There is one working example of a Generator, the ListGenerator which takes the List of parameters as an constructor argument.

Example usage looks like this:

public class SimpleExampleTest {

    @Rule
    public Generator<String> params = 
        new ListGenerator(asList("alpha", "beta", "gamma"));

    @Test
    public void testSomething() throws Exception {
        assertTrue(params.value().length() >= 4);
    }
}

I also blogged about it here: http://blog.schauderhaft.de/2012/12/16/writing-parameterized-tests-with-junit-rules/