Closed axetroy closed 4 years ago
edit:
it seems mainHandler
property of router is nil
I create a router via app := iris.New()
It should be compatible with http.Handler
It should be used for net/http/httptest
directly, but for now, it is not
@axetroy you use use the app.Build()
first, that builds the main handler:
app := iris.New()
// your routes here
app.Build()
app.ServeHTTP(w,r) is available now.
However I highly recommend using the github.com/kataras/iris/v12/httptest
instead. Gin does not have its own testing library, Iris is using the great httpexpect library to provide its own helpers to make your life easier, example with basic authentication like yours: https://github.com/kataras/iris/blob/c5b6ff1dd14165f3775c2f1c6558bdac79ba8a76/_examples/testing/httptest/main_test.go#L20
Thx. it works for me
You're welcome @axetroy!
Hi.
I used to write a project using gin, and now I am going to use iris
After my rewriting is completed, everything is fine, and it can be compiled and run normally
Only test cases fail
According to the stack information, I found here
It looks like everything is ok and there are no null pointers
The same test case is possible under the gin framework
I know that iris has a testing framework, but due to the high cost of migration, it is unlikely to change