I am trying to run basic unit tests and run on Play! using the Siena save library with GAE as the intended deployment target.
I set up the project correctly and can deploy the application for GAE. I created the base domain object:
public class User extends Model {
@Id(Generator.AUTO_INCREMENT)
public Long id;
@Column("first_name")
public String firstName;
@Column("last_name")
public String lastName;
@Column("email")
public String email;
public User(String firstName, String lastName, String email) {
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}
public static Query<User> all() {
return Model.all(User.class);
}
}
and basic unit test:
public class BasicTest extends UnitTest {
@Before
public void setup() {
Fixtures.deleteAll();
}
@Test
public void canCreateUser() {
new User("Jason","Miesionczek","atmospherian@gmail.com").insert();
User user = User.all().fetch().get(0);
assertNotNull(user);
assertEquals(1,User.all().count());
}
}
I understand that on Play! 1.0.3, support for Fixtures for Siena does not yet exist, which should be fixed in 1.1, but at the same time, what should I use instead of Fixtures.deleteAll () to clear the db test before each test?
Currently, my second statement fails because the database saves previously inserted records.