gospec icon indicating copy to clipboard operation
gospec copied to clipboard

Make *testing.T object available from inside spec functions

Open rafrombrc opened this issue 12 years ago • 4 comments

I've hit a hiccup trying to use gomock w/ gospec b/c creating a gomock controller requires access to the testing object that go usually passes in to tests. Ideally there'd be a way to get access to the lower level testing object from within the spec functions, possibly as a method call on the context object.

rafrombrc avatar Oct 22 '12 19:10 rafrombrc

+1. I might see if I can hack some code in that allows this and PR it.

xyzjace avatar Nov 26 '13 02:11 xyzjace

I'd like this functionality as well. @orfjackal, any plans to merge this in? @rafrombrc, any plans to merge this in your fork?

jveldridge avatar Jul 10 '14 19:07 jveldridge

@jveldridge No, I worked around it. Turned out I was able to appease gomock w/ a simple, fake testing context, see https://github.com/mozilla-services/heka/blob/dev/pipeline/testsupport/support.go#L36.

In other news, I haven't been very happy w/ gomock, wouldn't really recommend it for use.

rafrombrc avatar Jul 10 '14 20:07 rafrombrc

Gotcha. I'm actually using testify (https://github.com/stretchr/testify/) having also been unhappy with gomock, but there's a similar issue. I'm likewise able to work around it, but seemed like this approach would be more elegant.

jveldridge avatar Jul 10 '14 20:07 jveldridge