Created
May 17, 2017 12:56
-
-
Save schaloner/187f8c51609a58a70afbcdd24e3b881e to your computer and use it in GitHub Desktop.
Increasing test performance using TestContainers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package be.objectify.tcexample.db; | |
import be.objectify.tcexample.AbstractUserDaoTest; | |
import be.objectify.tcexample.UserDao; | |
import org.junit.After; | |
import org.junit.Before; | |
import org.junit.ClassRule; | |
import org.testcontainers.containers.PostgreSQLContainer; | |
import play.db.Database; | |
public class FasterJooqUserDaoTest extends AbstractUserDaoTest implements DbTestSupport, | |
TestData { | |
@ClassRule | |
public static PostgreSQLContainer postgres = new PostgreSQLContainer(); | |
private Database database; | |
@Before | |
public void setup() throws Exception { | |
database = create(postgres); | |
loadTestData(database); | |
} | |
@After | |
public void tearDown() { | |
destroy(database); | |
} | |
@Override | |
public UserDao dao() { | |
return new JooqUserDao(database); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package be.objectify.tcexample.db; | |
import be.objectify.tcexample.AbstractUserDaoTest; | |
import be.objectify.tcexample.UserDao; | |
import org.junit.After; | |
import org.junit.Before; | |
import org.junit.Rule; | |
import org.testcontainers.containers.PostgreSQLContainer; | |
import play.db.Database; | |
public class JooqUserDaoTest extends AbstractUserDaoTest implements DbTestSupport, | |
TestData { | |
@Rule | |
public PostgreSQLContainer postgres = new PostgreSQLContainer(); | |
private Database database; | |
@Before | |
public void setup() throws Exception { | |
// the database has all evolutions applied | |
database = create(postgres); | |
// load some test data | |
loadTestData(database); | |
} | |
@After | |
public void tearDown() { | |
destroy(database); | |
} | |
@Override | |
public UserDao dao() { | |
return new JooqUserDao(database); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment