• Stars
    star
    887
  • Rank 49,905 (Top 2 %)
  • Language
    HTML
  • License
    Apache License 2.0
  • Created almost 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Parameterised tests that don't suck

JUnitParams

Build Status Coverage Status Maven Central

Parameterised tests that don't suck

Example

@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

Latest News

  • 2017-11-03 JUnitParams 1.1.1 released. Check release info.

more news here

About

JUnitParams project adds a new runner to JUnit and provides much easier and readable parametrised tests for JUnit >= 4.12.

Main differences to standard JUnit Parametrised runner:

  • more explicit - params are in test method params, not class fields
  • less code - you don't need a constructor to set up parameters
  • you can mix parametrised with non-parametrised methods in one class
  • params can be passed as a CSV string or from a parameters provider class
  • parameters provider class can have as many parameters providing methods as you want, so that you can group different cases
  • you can have a test method that provides parameters (no external classes or statics anymore)
  • you can see actual parameter values in your IDE (in JUnit's Parametrised it's only consecutive numbers of parameters):

Quickstart

JUnitParams is available as Maven artifact:

<dependency>
  <groupId>pl.pragmatists</groupId>
  <artifactId>JUnitParams</artifactId>
  <version>1.1.1</version>
  <scope>test</scope>
</dependency>

To use JUnitParams in a Gradle build add this to your dependencies:

testCompile 'pl.pragmatists:JUnitParams:1.1.1'

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

Integration with Spring framework

Since spring version 4.2 it is possible to integrate JUnitParams and spring. More about this here.

More Repositories

1

tdd-trainings

Java
150
star
2

microfrontends

JavaScript
101
star
3

eventsourcing-java-example

A simplified (in memory) example of Event Sourcing implementation for banking domain.
Java
92
star
4

DDD-ADM

Anemic Domain Model example
Java
37
star
5

terraform-structure-sample

HCL
31
star
6

angular-test-runner

Test Angular stuff without ngMock.
JavaScript
30
star
7

ng-test-runner

TypeScript
24
star
8

junitparams-spring-integration-example

Example of JUnitParams integration with Spring
Java
15
star
9

vending-machine-kata

Shell
11
star
10

ddd-clean-validation

Java
10
star
11

react-hooks-demo

Examples of React Hooks
JavaScript
8
star
12

elevator-kata

Java
7
star
13

DDD-validation

Java
5
star
14

ddd-issues

Sample project for Domain-Driven Design workshops
Java
5
star
15

concordion-rest-extension

Non-official extension to Concordion that provide support for writing executable specifications for REST services
JavaScript
4
star
16

smelly-code-app

Java
2
star
17

movie-rental-kata

C#
2
star
18

reducing-complexity

A project demonstating how to reduce code complexity
Java
2
star
19

concordion-rest-extension-example

Java
2
star
20

tdd-ecommerce-app

Java
2
star
21

angular-elements-component

Simple HelloComponent in Angular Elements.
TypeScript
2
star
22

bonus-calculator-java

TDD training kata inspired by trainigng provided by Industrial Logic.
Java
1
star
23

roman-numerals-kata

JavaScript
1
star
24

open-trapp-ui

New OpenTrapp UI written in React with support for mobile devices
TypeScript
1
star
25

builders-kata

Java
1
star
26

bonus-calculator-js

TDD training kata inspired by trainigng provided by Industrial Logic.
JavaScript
1
star
27

tdd-csharp-day1

C#
1
star
28

legacy-code-exercises

Java
1
star
29

ddd-promotions

Java
1
star
30

async-jest

JavaScript
1
star
31

rspec-oracle-tdd-workshop

Ruby
1
star
32

ci-training-jenkins-jobs

Groovy
1
star
33

employee-refactoring-kata

Java
1
star
34

ddd-bounded-context-integration

Java
1
star
35

gilded-rose-java

Java
1
star
36

tdd-todos-app-react

Todos in React
JavaScript
1
star
37

tdi-cookbook-example

A worked example of test-driving a chef cookbook from the book 'Test Driven Infrastructure with Chef', 2nd edition
Ruby
1
star
38

tdd-java-day1

Training exercises for Test-Driven Development workshop in Java
Java
1
star
39

cdc_consumer_example

Java
1
star
40

frontend-interview

JavaScript
1
star
41

data-migration-testing

Example code for the Automating data migration testing blog post
JavaScript
1
star
42

barbershop

JavaScript
1
star
43

spring-routes

Java
1
star