Skip to content

Instantly share code, notes, and snippets.

@DarylWM
Created November 29, 2013 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DarylWM/7701409 to your computer and use it in GitHub Desktop.
Save DarylWM/7701409 to your computer and use it in GitHub Desktop.
import cucumber.api.java.Before;
import play.test.TestBrowser;
import play.test.TestServer;
import static play.test.Helpers.*;
public class GlobalHooks {
public static int PORT = 3333;
public static TestBrowser TEST_BROWSER;
private static TestServer TEST_SERVER;
private static boolean initialised = false;
@Before
public void before() {
if (!initialised) {
TEST_SERVER = testServer(PORT, fakeApplication(inMemoryDatabase()));
TEST_BROWSER = testBrowser(HTMLUNIT, PORT);
start(TEST_SERVER);
initialised = true;
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
TEST_BROWSER.quit();
TEST_SERVER.stop();
}
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment