Skip to content

Instantly share code, notes, and snippets.

@kardolus
Last active September 24, 2022 14:02
Show Gist options
  • Save kardolus/c64105b6817eb7f1551d022341017a05 to your computer and use it in GitHub Desktop.
Save kardolus/c64105b6817eb7f1551d022341017a05 to your computer and use it in GitHub Desktop.
package client_test
import (
"math"
"testing"
)
func TestUnitClient(t *testing.T) { // go test will hit this method
t.Run("Client Test", testClient)
}
func testClient(t *testing.T) { // You can make a bunch of these and iterate over them
got := math.Abs(-1)
if got != 1 {
t.Errorf("this should pass") // Example of an assertion passing
}
got = math.Abs(-1)
if got != 2 {
t.Errorf("this should fail") // Example of an assertion failing
}
}
// See also: https://golang.org/pkg/testing/
package bla_test
import (
"testing"
. "github.com/onsi/gomega"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
)
func TestUnitSomeClass(t *testing.T) {
spec.Run(t, "Testing Something", testSomething, spec.Report(report.Terminal{}))
}
func testSomething(t *testing.T, when spec.G, it spec.S) {
it.Before(func() {
RegisterTestingT(t)
})
when("SomeMethod()", func() {
it("has some behavior", func() {
// Expect bla bla
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment