I wrote a acceptance test to in a Play! 2 Framework, my test is:
@Test
public void goToIndexPageAT() {
running(testServer(3333, fakeApplication(inMemoryDatabase())), HTMLUNIT, new Callback<TestBrowser>() {
public void invoke(TestBrowser browser) {
browser.goTo("http://localhost:3333/");
assertThat(browser.url()).isEqualTo("http://localhost:3333/activities");
assertThat(browser.$("#title").getTexts().get(0)).isEqualTo("FitTime");
}
});
}
But when I try run this test using the command play test I got a error:
Test acceptenceTest.ApplicationTest.goToIndexPageAT failed: Server is not started!
[error] at scala.sys.package$.error(package.scala:27)
[error] at play.api.test.TestServer.stop(Selenium.scala:116)
[error] at play.test.Helpers.stop(Helpers.java:308)
[error] at play.test.Helpers.running(Helpers.java:338)
[error] at acceptenceTest.ApplicationTest.goToIndexPageAT(ApplicationTest.java:17)
What did I do wrong?
Thanks
I reproduced this error message by using port 3333 for another application and then starting the test.
Maybe you have previously ran the test and it didn’t shutdown correctly.
You can find it’s PID with
netstat -onap |grep 3333 # I used it with Linux
Example output:
tcp6 0 0 :::3333 :::* LISTEN 13173/java aus (0.00/0/0)
Kill the process:
kill -9 13173