YAML Test Fixtures for JPA
Java Groovy
Latest commit 066e83e Nov 15, 2013 @sberan Merge pull request #19 from eskatos/feature/libraries-upgrade
Upgrade all dependencies to the latest version available


Fixy : Yaml fixtures for Java

Build Status

Winner - 2012 10gen Open Source Hackathon

"Fixy has made my unit-testing life (outside of using Play framework) quite a bit easier" -Fixy User

Fixy makes unit testing your persistence layer much easier using SnakeYAML to create test fixtures and persist them to your database. It's similar to Rails and Play! Framework's test fixtures, with a few goodies added such as package declaration, imports, and processors

Supported Persistence Frameworks:

  • JPA
  • Morphia (MongoDB)

Example (using JPA)


- !package com.innotech

- Employee(bill):
    firstName: Bill
    lastName: Lumbergh

- Employee(peter):
    firstName: Peter
    lastName: Gibbons
    manager: Employee(bill)

Now use your fixtures from Java: (assuming you have a transaction active)

//load fixtures
Fixy fixtures = new JpaFixyBuilder(entityManager).build();

//run query
Employee peter = entityManager.createNamedQuery("developers", Employee.class).getSingleResult();

assertEquals("Gibbons", peter.getLastName());
assertEquals("Lumbergh", peter.getManager().getLastName());


Fixy allows you to import fixtures between files. You can even refer to entities created in other files.


- !package com.innotech

- !import employees.yaml

- Department(development):
        - Employee(peter)
        - Employee(samir)
        - Employee(michael)

Package declarations are scoped to the file, and files are guaranteed to only import one time, regardless of how many times they are declared.


Processors allow you to simulate stored procedures and other logic before your entities get persisted. New entities can be added via the processor as well.


Fixy fixtures = new JpaFixyBuilder(entityManager).build();
fixtures.addProcessor(new Processor<Employee>(Employee.class) {
    public void process(Employee emp) {
        emp.setName(emp.getFirstName() + " " + emp.getLastName());


The Fixy jars are located in My Repository.

If you're using Maven, simply add my Maven repository:


And the Fixy dependency:






  • Sam Beran (@sberan)
  • Chris Collison (@collisonchris)
  • Mohamed Mounirou (@mmounirou)
  • Jens Nehlmeier (@jnehlmeier)

Additional Documentation

See the JPA unit tests for some great usage examples.