stretchr / testify

A toolkit with common assertions and mocks that plays nicely with the standard library
MIT License
22.51k stars 1.56k forks source link

Using testify flags with dependency that does "flag.Parse()" in init() #590

Open joosep-wm opened 6 years ago

joosep-wm commented 6 years ago

Hi

I'd like to use -testify.m flag and also a dependency that's using flag.Parse() in it's init() function. Right now it's not possible, because flag.Parse() from dependency does not know about the "testify.m" flag and fails.

Is there some workaround for this or some other way to run a single method?

Here's an example project that illustrates this problem: https://github.com/joosep-wm/flaggery Just run "runtest.sh" to see the error.

prashantgupta24 commented 5 years ago

I also face an issue while using "github.com/spf13/pflag"and doing a pflag.Parse() in an init() function.

I get unknown shorthand flag: 't' in -testify.m. Any help would be appreciated!

prashantgupta24 commented 5 years ago

@joosep-wm did you figure out a way to run a single method while using parse()?