You are viewing the documentation for the 2.0.2 release in the 2.0.x series of releases. The latest stable release series is 3.0.x.

§Testing your application

Test source files must be placed in your application’s test folder. You can run tests from the Play console using the test and test-only tasks.

§Using JUnit

The default way to test a Play 2 application is with JUnit.

package test;

import org.junit.*;

import play.mvc.*;
import play.test.*;
import play.libs.F.*;

import static play.test.Helpers.*;
import static org.fest.assertions.Assertions.*;

public class SimpleTest {

    public void simpleCheck() {
        int a = 1 + 1;


§Running in a fake application

If the code you want to test depends on a running application, you can easily create a FakeApplication on the fly:

public void findById() {
  running(fakeApplication(), new Runnable() {
    public void run() {
      Computer macintosh = Computer.find.byId(21l);

You can also pass (or override) additional application configuration, or mock any plugin. For example to create a FakeApplication using a default in-memory database:


Next: Writing functional tests