POSTS

Play - Caused by: java.lang.RuntimeException: There is no started application

Problem:

Caused by: java.lang.RuntimeException: There is no started application

Solution:

Tests under under Playframework need to be run inside fakeApplication()
source: https://www.playframework.com/documentation/2.0/JavaTest
<![CDATA[ import static org.fest.assertions.Assertions.assertThat; import static play.test.Helpers.fakeApplication; import static org.fest.assertions.Assertions.assertThat; import static play.test.Helpers.fakeApplication; import static play.test.Helpers.running; import org.junit.Test; import play.data.validation.ValidationError; public class AllTests { @Test public void validateBirthdate() { running(fakeApplication(), new Runnable() { public void run() { User user = new User(); List errors = new ArrayList(); user.ValidateDate(“dd/mm/yyyy”, “32/01/2015”, errors); // must fail user.ValidateDate(“dd/mm/yyyy”, “01/13/2015”, errors); // must fail user.ValidateDate(“dd/mm/yyyy”, “01/01/2015”, errors); // must pass assertThat(errors.size()).isEqualTo(1); // total errors = 2 } }) } ]]>
SyntaxHighlighter.highlight();