commit | c43ede0d208d32efb10b3116c1fb21a2c4f5b176 | [log] [tgz] |
---|---|---|
author | android-build-team Robot <android-build-team-robot@google.com> | Fri Apr 13 09:32:17 2018 +0000 |
committer | android-build-team Robot <android-build-team-robot@google.com> | Fri Apr 13 09:32:17 2018 +0000 |
tree | e86151dc298945d36964e6aceda3e07bc4832d8f | |
parent | 4f0b0c84c6d6b1f462849fe7a10fb56309e1f9aa [diff] | |
parent | 16e4e7702709e21f3abd2661dc1fc852d2b5c800 [diff] |
Snap for 4719555 from 16e4e7702709e21f3abd2661dc1fc852d2b5c800 to qt-release Change-Id: I629f95f26c0a0ca9903be426ce9f1e5f1fe491b6
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/