Search code examples
javaplayframeworkbackendplayframework-1.x

How to avoid database auto clear when running Play Framework test?


I want to run serveral unit test and functional test on my Play Framework App(Play 1.4.0). A Test class like:

public class StatisticTest extends UnitTest {

    @Test
    public void testOutputStatistics() {
        //code
    }
}

And I have some data in my database which the test class need to read. But the Play test will clear all data in the database automatically. I have to import my data via SQL by using Fixtures.executeSQL() every time. This lowers the efficiency. So I want to know how can I avoid this auto clear.


Solution

  • In application.conf, set the test.jpa.ddl as "update" rather than "create".

    %test.jpa.ddl=update