I think in general that will be very hard to do, generically. The reason is, that the precise edge cases in which the behavior is critical depend so much on your implementation.
The best I can think of would be to write a wrapper which checks the invariants given and run your implementation-specific testsuite using that. Or to fuzz it. I'm aware that this doesn't answer your question (it's hard to prove a negative and AFAIK the answer is "no"), but maybe it explains why the problem is non-trivial. FTR, I would be interested in something like that too. On Mon, Aug 21, 2017 at 9:42 PM, Carl <carle...@gmail.com> wrote: > Satisfying a standard interface like io.Reader or io.Writer correctly is > not just a matter matching the function signatures, but rather adhering to > behaviour that is documented in comments > <https://golang.org/pkg/io/#Reader> > > Is there a standard way for me to specify an implementation of such an > interface and run an existing suite of tests against it that verify the > behaviour is indeed as expected? > > So, in other words, does something like testing.TestBehaviour( > myReader,io.Reader) or testing.SatisfiesIoReader(myReader) exist? > > To clarify, I'm not asking how to write tests that verify the > implementation of a standard interface. > Rather, I want to know if there is a way I can reuse tests that already > exist for an implementation that I wrote? > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.