Use Prettify to convert raw Go test names (such as those produced by go test -json) into human-readable sentences. It handles camel-case transitions, underscores, and subtest separators (/) to reverse the transformations applied by the Go testing package.
Handling Multi-word Function Names
Because Go function names are often camel-cased, Prettify might struggle to distinguish between a function name and the rest of the test description. To resolve this ambiguity, you can insert an underscore (_) immediately after the function name in the input string. This tells Prettify to treat the preceding words as a single multi-word function name.
Debugging
If you need to see the internal decision-making process of the prettifier, set the GOTESTDOX_DEBUG environment variable. This will cause Prettify to output detailed logs to the DebugWriter stream.
import "github.com/bitfield/gotestdox"
// Example 1: Standard subtest
// Input: "TestFoo/has_well-formed_output"
// Output: "Foo has well-formed output"
result := gotestdox.Prettify("TestFoo/has_well-formed_output")
// Example 2: Resolving multi-word function names
// Input: "TestHandleInput_ClosesInputAfterReading"
// Output: "HandleInput closes input after reading"
result = gotestdox.Prettify("TestHandleInput_ClosesInputAfterReading")