jin5011 发表于 2016-11-23 06:11:22

Go 语言极速 web 框架 IRIS V4.6.0 发布

import (  
    "github.com/kataras/iris/httptest"
  
    "github.com/kataras/iris"
  
    "testing"
  
)
  

  
func MyTest(t *testing.T) {
  
    // make sure that you reset your default station if you don't use the form of app := iris.New()
  
    iris.ResetDefault()
  

  
    iris.Get("/mypath", func(ctx *iris.Context){
  
      ctx.Write("my body")
  
    })
  

  
    e:= httptest.New(iris.Default, t)
  
    // with configs: e:= httptest.New(iris.Default, t, httptest.ExplicitURL(true), httptest.Debug(true))
  
    e.GET("/mypath").Expect().Status(iris.StatusOK).Body().Equal("my body")
  
}
页: [1]
查看完整版本: Go 语言极速 web 框架 IRIS V4.6.0 发布