2

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 

4 Answers 4

5

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.

1
  • this helped me ;-) looks like caching is the evil (but it helps to perform quicker)
    – bartosz.r
    Nov 6, 2012 at 22:00
1

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.

4
  • Yes, it is placed in the test folder in the defualt package, thus no package but the class in the root of test folder...
    – adis
    Apr 26, 2012 at 13:33
  • hmm, why are these dependencies needed, I did not saw this in the play documentation? But good to know that there is no web interface, I was expecting one :-)
    – adis
    Apr 27, 2012 at 14:25
  • Unfortunately this does not work for me, I still get the message no tests to run, do I need to extend a class like in PLay v1? Like FunctionalTest??
    – adis
    Apr 27, 2012 at 14:35
  • My bad, I've mixed up Scala and Java version of the framework. I might be mistaken but try changing your class name : LoginTest. Apr 27, 2012 at 15:10
0

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.

0

I fixed it by adding "extends TestCase". Only the @Test annotation is not enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.