我想测试我的模板play framework 2.1.*
路线代码:
# Home page
GET / controllers.Application.index()
POST /signup controllers.Application.signup()
控制器是:
public class Application extends Controller {
final static Form<User> usr=form(User.class);
public static Result index() {
return ok(index.render(usr));
}
和查看部分是:
index.scala.html
@(signupform: Form[User])
@import helper._
@import helper.twitterBootstrap._
@main("welcome to EXTR ") {
<div class="container-narrow">
<fieldset>
<legend>Sign up or <a href="@routes.signin.page" >Sign in</a></legend>
@helper.form(action=routes.Application.signup()){
@inputText(
signupform("username"),
'_label->"Enter Username",
'_help -> "Please Enter a valid username.",
'_error -> signupform.globalError)
@inputText(
signupform("name"),
'_label->"Enter name",
'_error -> signupform.globalError)
@inputPassword(
signupform("password"),
'_label->"Enter Password",
'_help -> "Please Enter a valid Password.",
'_error -> signupform.globalError)
@inputPassword(
signupform("repassword"),
'_label->"Enter Password again",
'_error -> signupform.globalError)
@inputText(
signupform("email"),
'_label->"Enter email",
'_help -> "Please Enter a valid Email",
'_error -> signupform.globalError)
<input class="btn btn-large " type="submit" value="signup" />
}
</fieldset></div>
}
现在我想测试index.scala.html
如何为此编写测试代码?
我试过但没有得到
@Test
public void renderTemplate() {
Content html = views.html.index.render(form(User.class));
assertThat(contentType(html)).isEqualTo("text/html");
assertThat(contentAsString(html)).contains("Coco");
}
但是当我运行没有得到任何回复时,它会继续运行吗?
所以给我一些想法为此编写代码?