Gotest is a test tool provided by the go language. It includes two types: unit test and performance test.

Source: Internet
Author: User
Gotest is a test tool provided by the go language. It includes two types: unit test and performance test.

Go test is a test tool provided by go. It includes two types: unit test and performance test.

Go help test shows how to use go test:

Format:

Go test [-c] [-I] [build flags] [packages] [flags for test binary]

Parameter explanation:

-C: compile go test as an executable binary file, but do not run the test.

-I: install the package on which the test package depends, but do not run the test.

For build flags, call go help build. these are the parameters that need to be used during compilation and running, and are generally set to null.

For packages, call go help packages. these are about package management and are generally set to null.

For flags for test binary, call go help testflag, which are frequently used parameters in the go test process.

-Test. v: whether to output all unit test cases (whether successful or failed). by default, no unit test cases are added. Therefore, only failed unit test cases are output.

-Test. run pattern: Only unit test cases

-Test. shortpatten: only the performance test cases are run.

-Test. benchmem: whether to output memory conditions during performance testing

-Test. benchtime t: The time when the performance test is run. the default value is 1 s.

-Test. cpuprofile cpu. out: whether to output the cpu performance analysis File

-Test. memprofile mem. out: whether to output the memory performance analysis File

-Test. blockprofile block. out: whether to output performance analysis files blocked by internal goroutine

-Test. memprofilerate n: indicates the number of records allocated during memory performance analysis. This parameter is used to set the memory allocation interval for hitting, that is, the memory size represented by a sample in profile. The default value is 512*1024. If you set it to 1, there will be a hitting point in the profile for every memory block allocated, so there will be a lot of sample profiles generated. If you set it to 0, you will not be hitting it.

You can disable memory reclaim by setting memprofilerate = 1 and GOGC = off, and observe the allocation of each memory block.

-Test. blockprofilerate n: the same as above. it controls the number of nanoseconds of hitting when a goroutine is blocked. If this parameter is not set by default, it is equivalent to-test. blockprofilerate = 1. record every nanosecond.

-Test. parallel n: number of concurrent CPUs of the performance test program. The default value is GOMAXPROCS.

-Test. timeout t: If the test case running time exceeds t, a panic is thrown.

-Test. cpu, 4: indicates the CPU on which the program runs, which is represented by the bit of binary 1, which is the same as nginx nginx_worker_cpu_affinity.

-Test. short: Shorten the running time of test cases with long running time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.