Last active
September 24, 2022 14:02
-
-
Save kardolus/c64105b6817eb7f1551d022341017a05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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