package teams; import io.restassured.RestAssured; import org.junit.Before; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.embedded.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.jdbc.SqlConfig; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Transactional; import teams.repository.MembershipRepository; import teams.repository.PersonRepository; import teams.repository.TeamRepository; import static org.springframework.test.context.jdbc.SqlConfig.ErrorMode.FAIL_ON_ERROR; import static org.springframework.test.context.jdbc.SqlConfig.TransactionMode.ISOLATED; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, value = {"spring.profiles.active=dev"}) @Transactional @Sql(scripts = {"classpath:sql/clear.sql", "classpath:sql/seed.sql"}, config = @SqlConfig(errorMode = FAIL_ON_ERROR, transactionMode = ISOLATED)) public abstract class AbstractApplicationTest { @Autowired protected MembershipRepository membershipRepository; @Autowired protected TeamRepository teamRepository; @Autowired protected PersonRepository personRepository; @LocalServerPort private int serverPort; @Before public void before() throws Exception { RestAssured.port = serverPort; } }