Hi Tong Sun
You may use the standard testing package <https://golang.org/pkg/testing/> 
and compare byte slices <https://golang.org/pkg/bytes/#Compare>.
For the source of truth, use current output as expected bytes, either 
hard-coded in test source, or read from a new folder that you would call 
"testdata".
For the new output to be tested, there are various ways of redirecting the 
os.Stdout and then read it in a []byte, but the super-clean way (no Stdout, 
no intermediate file) would be to provide your own (*bytes.Buffer 
<https://golang.org/pkg/bytes/#Buffer>) to the program processing, which 
may need to be refactored to write to a configurable io.Writer 
<https://golang.org/pkg/io/#Writer>.
HTH
Val

On Thursday, April 13, 2017 at 7:35:42 PM UTC+2, Tong Sun wrote:
>
> My program works on files, read from input and write to output. 
>
> Is there any ready-made and *light *testing packages that allows me 
> checking whether the new output is the same as before? 
>
> Thanks
>
>
>

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