Hello,

I'd suggest wrapping your main to create a more testable interface.  For 
example, see https://play.golang.org/p/_Zund5W4fb5.



On Thursday, 11 April 2019 04:57:24 UTC-4, hui zhang wrote:
>
> my program take 4 args like          
> ./myprogram   1 2 3 4
> *args_len=: 5*
> I want to test this program coverage so  
> go test -coverprofile coverage.out  -args 1 2 3 4
>
> myprogram_test.go
>
> func Test_main(m *testing.T) {
>    main()
>
> }
>
>
> DEBUG  args= 
> [/var/folders/cp/561_gl9j1wzd8dgv_fn5mk7c0000gn/T/go-build225076203/b001/myprogram.test
>  
> -test.coverprofile=/var/folders/cp/561_gl9j1wzd8dgv_fn5mk7c0000gn/T/go-build225076203/b001/_cover_.out
>  
> 1 2 3 4]
> ERROR  invalid *args_len=: 6*
>
> the coverage flag has been add to args   cause program error,   invalid 
> args_len=: 6   
> How to resolve this ?
>
>

-- 
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.

Reply via email to