moconvey

module
v0.0.0-...-f0583b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2020 License: MIT

README

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")
			})
		})
	})
}

Directories

Path Synopsis
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL