Open
Description
There is such a wonderful thing in Django as response.context
. It let access data which has been used for rendering of templates. In case of Revel it could look like:
// app.go (Just usual Revel application which renders something)
func (c *App) Profiles() revel.Result {
profiles := models.Profiles()
return c.Render(profiles)
}
// apptest.go
func (t *TestSuite) TestThatProfilesListWorks() {
t.Get("/app/profiles")
t.AssertEqual(1, len(t.Response.RenderArgs["profiles"]))
t.AssertEqual("John Doe", t.Response.RenderArgs["profiles"][0].Fullname)
}
Thus it is possible to better test the correctness of controllers' work. And changes in templates will not break all the tests.