Skip to content

MarkyMarkMcDonald/FactoryJill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FactoryJill

Usage

sourceCompatibility = 1.8
dependencies {
    testCompile('com.github.markymarkmcdonald:FactoryJill:2.0.0')
}

Features

Supported:

  • Defining reusable factories
  • Overriding fields
  • Associations: Defining fields as instances of other factories
  • Building a list of factories

Not Supported:

  • Aliases
  • Sequences

Not Planned to be supported:

  • Factory Inheritance
  • Lazily setting fields (based off of other properties)
  • Callbacks (pre-build, post-build)

Requirements

  • Java 8
  • A public getter and setter for each field defined or overridden.

Examples

Defining a factory:

factory("truck", Car.class, ImmutableMap.of(
                "make", "ford",
                "convertible", false,
                "yearsOwned", 5,
                "releaseDate", new Date()
        ));

Building an instance from a factory:

Car pickupTruck = build("truck");

Sometimes you need to override specific properties:

Car convertible = build("truck", ImmutableMap.of("convertible", true));

Building multiple instances from a factoy:

List<Car> pickupTrucks = buildMultiple("truck", 5);

Full API

For now FactoryJill provides a public interface with three methods, FactoryJill.factory, FactoryJill.build, and FactoryJill.buildMultiple. Check out the test directory for a complete set of usage examples.

About

A library for setting up Java objects as test data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages