Play Framework (2.1.3) doesn't run any tests

java, junit, playframework

Solution

It's a known issue of Play 2.1.3. Meanwhile there is a workaround. Add the following into Build.scala file in the val main function:

val main = play.Project(appName, appVersion, appDependencies).settings(
  // Add your own project settings here      
  testOptions in Test ~= { args =>
    for {
      arg <- args
      val ta: Tests.Argument = arg.asInstanceOf[Tests.Argument]
      val newArg = if(ta.framework == Some(TestFrameworks.JUnit)) ta.copy(args = List.empty[String]) else ta
    } yield newArg
  }
)   

Problem

I have 4 test classes with an average of two test functions each. The first test is below and must be correct (its from Play's tutorial). ``` public class ApplicationTest { @Test public void simpleCheck() { int a = 1 + 1; assertThat(a).isEqualTo(2); } } ``` The other ones are custom made and have a `@Before` setup, like this: ``` public class UserTest extends WithApplication { @Before public void setUp() { start(fakeApplication(inMemoryDatabase())); } // creation and retrieval of user @Test public void createAndRetrieveUser() { new User("bob@gmail.com", "Bob", "secret").save(); User bob = User.find.where().eq("email", "bob@gmail.com").findUnique(); assertNotNull(bob); // successfully retrieved assertEquals("Bob", bob.getName()); // correct user retrieved } } ``` Now when I run `play test` it finishes a lot quicker and doesn't execute any test. ``` PS C:\wamp\www\dcid> play test [info] Loading project definition from C:\wamp\www\dcid\project [info] Set current project to dcid (in build file:/C:/wamp/www/dcid/) [info] Compiling 4 Java sources to C:\wamp\www\dcid\target\scala-2.10\test-classes... [info] ApplicationTest [info] [info] [info] Total for test ApplicationTest [info] Finished in 0.014 seconds [info] 0 tests, 0 failures, 0 errors [info] models.UserTest [info] [info] [info] Total for test models.UserTest [info] Finished in 0.002 seconds [info] 0 tests, 0 failures, 0 errors [info] models.ProposalTest [info] [info] [info] Total for test models.ProposalTest [info] Finished in 0.002 seconds [info] 0 tests, 0 failures, 0 errors [info] Passed: : Total 0, Failed 0, Errors 0, Passed 0, Skipped 0 [success] Total time: 5 s, completed 16/Ago/2013 14:52:35 ``` Why is this? What can I do? I recently updated from play 2.1.2 to 2.1.3. I updated all references and the project is working fine, except the tests. I also looked at this question, but it can't be that, since I didn't change my tests, so they are well written, it's just their execution that is not working.

Original source