Skip to content

KFixture is a Kotlin wrapper for the JFixture library

Notifications You must be signed in to change notification settings

FlexTradeUKLtd/kfixture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KFixture

KFixture is a Kotlin wrapper around JFixture.

Build Status

Usage

Import it into maven as so:

<dependency>
	<groupId>com.flextrade.jfixture</groupId>
	<artifactId>kfixture</artifactId>
	<version>1.0.0</version>
	<scope>test</scope>
</dependency>

Create an instance, and invoke it to create fixtured values:

val kFixture = KFixture()

val integer = kFixture<Int>()
val myObject: SomeObject = kFixture()

Numerical Ranges

To create a range for integers, call .intRange(..). However, the upper limit is exclusive. The example below creates an integer fixture between 0 and 4:

val integer = kFixture.intRange(0..5)

Customisation

To customise your KFixture, just pass a body as a parameter:

val kFixture = KFixture {
    circularDependencyBehaviour().omitSpecimen()
}

Ignoring default arguments on constructors

val kFixture = KFixture {
    add(IgnoreDefaultArgsConstructorCustomisation())
}

To fixture classes where every argument has a default value, use this customisation. This will apply to all fixtures generated using this instance.

About

KFixture is a Kotlin wrapper for the JFixture library

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages