go testing 패키지 사용중 주의점
By SeukWon Kang
go 언어는 테스팅을 위한 전용 패키지 testing을 가지고 있어 아주 유용하게 사용할수 있습니다.
다만 이를 사용할때는 source code의 naming rule을 따라야 하는데 테스트할소스코드이름_test.go 형태를 지켜야 합니다.
이를 지키지 않으면 flag 패키지를 사용해서 command line argument를 받는 프로그램 작성시 -? 등으로 command line help를 보게 되면
-test.bench="": regular expression to select benchmarks to run -test.benchmem=false: print memory allocations for benchmarks -test.benchtime=1s: approximate run time for each benchmark -test.blockprofile="": write a goroutine blocking profile to the named file after execution -test.blockprofilerate=1: if >= 0, calls runtime.SetBlockProfileRate() -test.coverprofile="": write a coverage profile to the named file after execution -test.cpu="": comma-separated list of number of CPUs to use for each test -test.cpuprofile="": write a cpu profile to the named file during execution -test.memprofile="": write a memory profile to the named file after execution -test.memprofilerate=0: if >=0, sets runtime.MemProfileRate -test.outputdir="": directory in which to write profiles -test.parallel=1: maximum test parallelism -test.run="": regular expression to select tests and examples to run -test.short=false: run smaller test suite to save time -test.timeout=0: if positive, sets an aggregate time limit for all tests -test.v=false: verbose: print additional output
과 같은 테스트용 인자의 도움말이 불필요하게 나오는 것을 볼수 있습니다.
잘 쓰고 있는 https://github.com/veandco/go-sdl2 패키지가 이를 지키지 않아서 몇시간을 고생해서?알아냈기에 여기에도 적어둡니다. ( issue report 도 했습니다. )