Skip to content

rnaufal/junit-parameters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

junit-parameters

Build Status

junit-parameters enables adding parameters to JUnit 4 test methods.

Code examples

  • Annotate your test class with the JUnitParameters test runner:
@RunWith(JUnitParameters.class)
public class ParametersGeneratorTest {
}
  • Implement the interface ParameterGenerator:
public class OneParameterGenerator implements ParameterGenerator {

    @Override
    public Iterable<Object[]> parameters() {
        return Arrays.asList(new Object[][] { { "foo" }, { "bar" }, 
                                              { "baz" }, { "code" },
                                              { "java" } });
    }
}
  • Use it in your test with the @ParameterProvider annotation
@Test
@ParameterProvider(OneParameterGenerator.class)
public void injectSingleParam(String parameter) {
}

The JUnit test method will be invoked with each parameter created by the ParameterGenerator factory used in the test.

Tests

There are some tests available at src/test/java. It's possible to run the JUnitParametersTest test class and see the results.

License

junit-parameters is licensed under the The MIT License (MIT)

About

junit-parameters enables adding parameters to JUnit 4 test methods

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages