Skip to content

gotestingmock mocking utilities for unit test in Go

License

Notifications You must be signed in to change notification settings

newmo-oss/gotestingmock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gotestingmock Go ReferenceGo Report Card

gotestingmock mocking utilities for unit test in Go.

Usage

func Test(t *testing.T) {
	t.Parallel()

	// gotestingmock.Run simulates a test function on a goroutine.
	got := gotestingmock.Run(func(tb *gotestingmock.TB) {
		// The test helper can use *gotestingmock.TB as testing.TB
		// which is implemented  by testing.T, testing.B and testing.F.
		MyTestHelper(tb, "arg1")
	})

	// Check if the test helper failed with t.Error, t.Fatal or similar methods.
	if !got.Failed {
		t.Error("expected failed did not occur")
	}

	// Check that the test helper has panicked.
	if got.PanicValue != nil {
		t.Error("unexpected panic:", got.PanicValue)
	}
}

License

MIT

About

gotestingmock mocking utilities for unit test in Go

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages