commit | 4be4b8b6c80aac6adae26a4249a63d1122020a7b | [log] [tgz] |
---|---|---|
author | Paul Duffin <[email protected]> | Wed Mar 22 22:08:26 2017 +0000 |
committer | android-build-merger <[email protected]> | Wed Mar 22 22:08:26 2017 +0000 |
tree | 949e76c140c6b5415b519eaf577c12dc8d704b14 | |
parent | f29c61a5fb5d60c73fd5cc5d26316d0c6df68f6d [diff] | |
parent | 63dd96c6f8df00a9521c30b1d2bc2ec942965c14 [diff] |
Make sure that filters affect the Description am: 99fe7c3891 am: 6c3f4570e0 am: 63dd96c6f8 Change-Id: Ia2a7e2ab316c022e19b52ab4fc54ca00490cbf79
Parameterised tests that don't suck
@RunWith(JUnitParamsRunner.class) public class PersonTest { @Test @Parameters({"17, false", "22, true" }) public void personIsAdult(int age, boolean valid) throws Exception { assertThat(new Person(age).isAdult(), is(valid)); } }
See more examples
JUnitParams project adds a new runner to JUnit and provides much easier and readable parametrised tests for JUnit >=4.6.
Main differences to standard JUnit Parametrised runner:
JUnitParams is available as Maven artifact:
<dependency> <groupId>pl.pragmatists</groupId> <artifactId>JUnitParams</artifactId> <version>1.0.4</version> <scope>test</scope> </dependency>
If you want to see just one simple test class with all main ways to use JUnitParams see here: https://github.com/Pragmatists/junitparams/tree/master/src/test/java/junitparams/usage
You can also have a look at Wiki:Quickstart
Note: We are currently moving the project from Google Code to Github. Some information may still be accessible only at https://code.google.com/p/junitparams/