私のような人がまだこの問題に対処しており、各テスト シナリオの後にロールバックする方法を探している場合に備えて、以下に有効な解決策を示します (Burt Beckwith のブログに感謝します)。
各 easyb テスト シナリオを with transaction ブロックでラップし、最後に手動でロールバックします。
scenario "add person should be successful", {
Person.withTransaction { status ->
given "no people in database", {
}
when "I add a person", {
Person.build()
}
then "the number of people in database is one", {
Person.list().size().shouldEqual 1
}
status.setRollbackOnly()
}
}
scenario "database rollback should be successful", {
given "the previous test created a person", {
}
when "queried for people", {
people = Person.list().size()
}
then "the number of people should be zero", {
people.shouldEqual 0
}
}
上記のテストはパスします。問題のより良い解決策があれば投稿してください