Skip to content

A collection of tools allowing for easier work with JUnit4 Theories

License

Notifications You must be signed in to change notification settings

artificialrevelations/teoria

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

teoria

A collection of paramter suppliers for JUnit 4 Theories runner. To learn more about the Theories runner of JUnit 4 experimental package please check the description on the project page.

Prerequisites

You can use this library in conjunction with JUnit 4.12. Currently the only available comfortable way to import the library is through the use of JITPACK.io:

In your build.gradle file at the end of repositories section add this line:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Add teoria to the list of your test dependencies:

	dependencies {
	        testImplementation 'com.github.foobaz42:teoria:master-SNAPSHOT'
	}

Using teoria

Teoria contains several suppliers for basic types:

  • IntsAbove, IntsBelow and IntsBetween
  • LongsAbove, LongsBelow and LongsBetween
  • DoublesAbove, DoublesBelow and DoublesBetween

You can write a test using them like this:

@RunWith(Theories.class)
public class FooTest {
    @Theory
    public void a_theory_about_values_that_are_above(@IntsAbove(value = 42) final Integer value) {
        // test ...
    }

    @Theory
    public void a_theory_about_values_that_are_below(@LongsBelow(value = 42L) final Long value) {
        // test ...
    }
    
    @Theory
    public void a_theory_about_values_that_are_between(@DoublesBetween(first = 1.0, last = 42.0) final Double value) {
        // test ...
    }
}