Reputation: 5951
I have written a simple test class for Play! 2.0:
public class TestLogin {
@Test
public void test() {
running(testServer(3333, fakeApplication(inMemoryDatabase())), HTMLUNIT, new Callback<TestBrowser>() {
@Override
public void invoke(TestBrowser browser) {
browser.goTo("http://localhost:3333");
assertThat(browser.$("section h1").first().getText()).isEqualTo("Login");
}
});
}
}
In Play v1 you could execute the command:
play test
And you are able to goto http://localhost:9000/@tests
. But now in Play 2.0 this does not work and it is not documented? I just want to start my Selenium tests, both manual (per testcase / method) as automated (a bunch of testcases).
How can this be achieved in Play2.0?
BTW: Runnning the command play test output the following in my terminal:
[warn] 1 warning
[info] No tests to run for test:test
Upvotes: 2
Views: 2595
Reputation: 5497
I fixed it by adding "extends TestCase". Only the @Test annotation is not enough.
Upvotes: 0
Reputation: 3449
You might try doing a play clean and then try play test again. I was getting the same "No tests to run" message until I did a clean.
Upvotes: 5
Reputation: 85
The point seems to be, that the test classes must be in the 'test' package. That means, you have to insert 'package test;' at the top of your java file.
For me this creates an error message in the IDE, but the 'test' command on the play console runs the test as expected.
Upvotes: 0
Reputation: 10404
Are they placed in the test
folder?
You are doing it right, otherwise. The command is indeed :
play test
But there is no web interface for test lauching. Everything goes through the command line.
Upvotes: 1