Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nil panic when method not called #31

Closed
rekby opened this issue May 1, 2019 · 0 comments · Fixed by #32
Closed

Nil panic when method not called #31

rekby opened this issue May 1, 2019 · 0 comments · Fixed by #32

Comments

@rekby
Copy link
Contributor

rekby commented May 1, 2019

If set return parameters without .Expected for method with arguments, then not call the method - minimock will panic on Finish.

tmp.go

package asd

import "testing"

type Int interface {
	M()
	MA(i int)
}

func TestExpected(t *testing.T) {
	m := NewIntMock(t)
	m.MMock.Return()

	// Work as expected: fail test because method not called
	m.MinimockFinish()
}

func TestNilPanic(t *testing.T) {
	m := NewIntMock(t)
	m.MAMock.Return() // for method with arguments

	// invalid memory address or nil pointer dereference. Bug.
	m.MinimockFinish()
}

generated code:
https://gist.github.com/rekby/3e95b03c8220cd5da895e8ccaa66bd44

rekby added a commit to rekby-forks/minimock that referenced this issue May 2, 2019
rekby added a commit to rekby-forks/minimock that referenced this issue May 2, 2019
rekby added a commit to rekby-forks/minimock that referenced this issue May 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant