GolangWeb開发之Revel测试.docxVIP

  • 17
  • 0
  • 约3.21千字
  • 约 5页
  • 2017-01-19 发布于重庆
  • 举报
GolangWeb開发之Revel测试

Golang Web开发之Revel测试Revel提供了一个测试框架,这使得在应用程序中写和运行测试函数变得很容易.skeleton应用程序带有一个简单的测试来帮助我们测试.概要测试保存在tests目录corp/myapp ??app/ ??conf/ ??public/ ??tests/?一个简单的测试看起来像下面这样:type?ApplicationTest?struct?{ ??rev.TestSuite ?} ??func?(t?ApplicationTest)?Before()?{ ??println(Set?up) ?} ??func?(t?ApplicationTest)?TestThatIndexPageWorks()?{ ??t.Get(/) ??t.AssertOk() ??t.AssertContentType(text/html) ?} ??func?(t?ApplicationTest)?After()?{ ??println(Tear?down) ?}?上面的示例代码展示了几件事:一个测试工具是任意嵌入rev.TestSuite的struct 如果存在 Before() 和 After() 方法, 它们将在每一个测试方法的前后被调用 rev.TestSuite 为发布请求到应用程序和断言响应信息提供帮助 一个断言失败产生一个panic, 它将被harne

文档评论(0)

1亿VIP精品文档

相关文档