Skip to content

goconvey style assertions for stretchr/testify mocks

License

Notifications You must be signed in to change notification settings

tamccall/moconvey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

moconvey

Build Status Go Report Card GoDoc

moconvey is a package that aims to better integrate the mocks of stretchr/testify and the testing framework that is goconvey

This package currently defines all of the assertions provided by the mock struct as convey style assertions so you will still be able to get those fancy green check marks for your mock assertions too.

This package was originally designed to work with mocks generated by mockery but should work with any mock using testify's mock package

Example

Here is an example test function testing a piece of code that operates on a mock called Foo. The test function can setup expectations (testify) for Foo and assert that they indeed happened:

package convey

import (
	"testing"
	
	. "github.com/tamccall/moconvey/assertions"
	. "github.com/smartystreets/goconvey/convey"
	
	"github.com/tamccall/moconvey/mocks"	
)

func TestExampleMock(t *testing.T)	{
	Convey( "Given the example mock" , t, func() {
		mock := new(mocks.Foo)
		mock.On("Bar").Return("Hello World")
		Convey("When Bar is called", func() {
			mock.Bar()
			Convey("Assert Bar is called", func() {
				So(mock, ShouldHaveReceived, "Bar")
			})
		})
	})
}

About

goconvey style assertions for stretchr/testify mocks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages