Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

msanecki/parameterizedTestsWithRules

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
5 Commits
 
 
 
 
 
 

Repository files navigation

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/

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.