How do you use control flags for gooc (golang) gocheck testing scheme?

How to use flag parameters for tests with gocheck testing platform? In the link I provided, it seems that the only example they provide is to run go test -check.b , however they do not provide additional comments on how this works, so it is difficult to use. I couldn't even find -check in the go documentation when I did go help test , and when I did go help testflag . In particular, I want to learn more about how to use the basic test platform, and control how long it works or how many iterations it runs, etc. Etc. For example, in the example, they provide:

 func (s *MySuite) BenchmarkLogic(c *C) { for i := 0; i < cN; i++ { // Logic to benchmark } } 

There is a variable cN How to specify this variable? Is it through the program itself, or is it through the go test, its flags or command line?

On the other hand, the documentation from go help testflag talked about the -bench regex , benchmem and benchtime t , but it did not talk about the -check.b option. However, I tried to run these parameters as described there, but in fact I did not notice anything. Does gocheck work with source parameters for go test ?

The main problem that I see is that there is no clear documentation on how to use the gocheck tool or its commands. I accidentally assigned him the wrong flag, and he threw me an error message suggesting useful commands that I need (what a limited description):

  -check.b=false: Run benchmarks -check.btime=1s: approximate run time for each benchmark -check.f="": Regular expression selecting which tests and/or suites to run -check.list=false: List the names of all tests that will be run -check.v=false: Verbose mode -check.vv=false: Super verbose mode (disables output caching) -check.work=false: Display and do not remove the test working directory -gocheck.b=false: Run benchmarks -gocheck.btime=1s: approximate run time for each benchmark -gocheck.f="": Regular expression selecting which tests and/or suites to run -gocheck.list=false: List the names of all tests that will be run -gocheck.v=false: Verbose mode -gocheck.vv=false: Super verbose mode (disables output caching) -gocheck.work=false: Display and do not remove the test working directory -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 

writes the wrong commands, the only way to get some help with this tool? doesn't he have a help flag or anything else?

+7
benchmarking go testing
source share
1 answer

see Description_of_testing_flags :

 -bench regexp Run benchmarks matching the regular expression. By default, no benchmarks run. To run all benchmarks, use '-bench .' or '-bench=.'. 

-check.b works the same way as -test.bench .

eg. To run all benchmarks:

 go test -check.b=. 

To run a specific test:

 go test -check.b=BenchmarkLogic 

more information on testing in Go can be found here.

+3
source share

All Articles