Testing in Golang


Gowitek

Uploaded on Aug 8, 2019

Category Education

Golang is a lightweight, new open-source language which has several features that make automated and manual testing easier. Due to feature-rich standard library support, it provides a desirable environment for running and writing tests.

Category Education

Comments

                     

Testing in Golang

Benefits of testing in Golang Introduction • Go is a modern open-source language that has several features which make manual as well as automated testing easier. • Go Test tool conducts writing tests at development time. • Golang provides code coverage analysis, displaying exact lines exercised by tests. • Following are some of the advantageous features Golang brings to testing environment: Logrus Logrus is a feature-rich structured logger for Golang. We can write logs asynchronously to avoid extra overhead on the system. Benefits: •  Due to asynchronous logging important resources can be saved for other priority tasks. •  Service Hooks such as Airbrake help in quick bug fixing and superior test code quality while Redis features in- memory data set. •  Efficiently track and write logs that result in neat and well- written code. Golang Benchcmp • The benchcmp command displays performance changes between benchmarks. Benchcmp parses the output of two 'go test' benchmark runs, correlates the results per benchmark, and displays the deltas. • By setting benchmarks we can easily compare system calls by understanding which piece/version of code performs better. Benefits: • Implement superior quality code which is free of any performance bottlenecks. Uber Go-Torch • Uber Go-Torch is a tool for stochastically profiling Go programs. It collects stack traces from Golang’s built-in pprof library and synthesizes this information into a flame graph. The flame graph generates data sets about Time consumption, Memory Consumption, CPU Usage and more. Benefits: • With so many inputs at their disposal, Uber Go-Torch helps developers to understand and optimize the code to improve system performance to the function level. • The resulting code is optimized for speed, CPU usage, memory usage, performance and time. Golang Pprof Golang Pprof is Golangs built-in Library. It continually generates data. By utilizing the Pprof tool we are able to perform CPU profiling of the system. It helps us analyze the CPU dump and then generate reports on performance in the CPU by generating a flame graph. Benefits: • When used in collaboration with Uber Go-Torch, Golang Pprof helps develop code that performs at an optimized level.