I want to set up a bunch of test
What command do i use to run them or link them to a fiber project?
How do i link a bunch of files with test functions on it?
Again, i am really sorry if this seems easy or obvious, i am quite new to go and fiber.
i would really appreciate some light on here.
I have already applied the examples below, i just dont get how to link them or run them
Hi @slalbertojesus, don't apologize for asking questions ( we all started somewhere ๐ )
I recommend watching this video https://www.youtube.com/watch?v=sOeUf1YICSA or https://www.youtube.com/watch?v=GlA57dHa5Rg that explains how to write unit tests.
You could also browse Fiber's root directory and check out the _test.go files https://github.com/gofiber/fiber, for example:
```go
// myfile_test.go
package main
import (
"net/http/httptest"
"testing"
fiber "github.com/gofiber/fiber"
utils "github.com/gofiber/utils"
)
// go test -run -v Test_Handler
func Test_Handler(t *testing.T) {
app := New()
app.Get("/test", func(c *Ctx) {
c.SendStatus(400)
})
resp, err := app.Test(httptest.NewRequest("GET", "/test", nil))
utils.AssertEqual(t, nil, err, "app.Test")
utils.AssertEqual(t, 400, resp.StatusCode, "Status code")
}
@slalbertojesus did my advice help you creating unit tests? We assume you don't need further help, feel free to re-open this issue if you have any more questions ๐
Most helpful comment
Hi @slalbertojesus, don't apologize for asking questions ( we all started somewhere ๐ )
I recommend watching this video https://www.youtube.com/watch?v=sOeUf1YICSA or https://www.youtube.com/watch?v=GlA57dHa5Rg that explains how to write unit tests.
You could also browse Fiber's root directory and check out the
_test.gofiles https://github.com/gofiber/fiber, for example:```go
// myfile_test.go
package main
import (
"net/http/httptest"
"testing"
)
// go test -run -v Test_Handler
func Test_Handler(t *testing.T) {
app := New()
}