Yaml-Fixtures for play 2 1

Posted by Jens J├Ąger on December 30, 2013

Fixtures is a fancy word for sample data. Fixtures allow you to populate your testing database with predefined data before your tests run.

The fixture implementation for loading testdata in play 1 was great. But all fixture related code for play 2 I found was ebean releated. After some research I decided to use Fixy for loading test data. It needed only some small changes to adapt it for play 2.

I added the code as a module to play4jpa. To use it, just copy the module to your project and add the necessary config to your Build.scala.

A yaml fixture file in the play conf folder can be loaded inside a transaction with this code:

The yaml for a Task Model with a name an done flag would look like this:

Check out the samples in the fixy unit tests on github for more details on using fixy.

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. […] startup, load an fresh in memory database and load the test related fixtures. You need fixy and this helper to do the […]

Comments

Information about Data protection