Skip to content

Instantly share code, notes, and snippets.

@azbshiri azbshiri/main.go
Last active Mar 27, 2018

Embed
What would you like to do?
Go already has RSpec!
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMain(m *testing.M) {
// before spec
err := m.Run()
// after spec
os.Exist(err)
}
func TestGetBook(t *testing.T) {
t.Run("ok", func (t *testing.T) {
// ....
assert.Equal(t, http.StatusOK, res.Code)
}
t.Run("unauthorized", func (t *testing.T) {
// ....
assert.Equal(t, http.StatusUnauthorized, res.Code)
}
// etc
}
@mdwhatcott

This comment has been minimized.

Copy link

mdwhatcott commented Mar 26, 2018

BTW, the before spec is only run once before all specs/tests, not before each.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.