The testing/quick Package

Let’s learn about opaque-box testing using the testing/quick package.

Opaque-box testing

There are times where we need to create testing data without human intervention. The Go standard library offers the testing/quick package, which can be used for opaque-box testing (a software testing method that checks the functionality of an application or function without any prior knowledge of its internal working) and is somewhat related to the QuickCheck package found in the Haskell programming language—both packages implement utility functions to help us with black box testing. With the help of testing/quick, Go generates random values of built-in types that we can use for testing, which saves us from having to generate all these values manually.

Coding example

The code of quickT.go is the following:

Get hands-on with 1200+ tech skills courses.