A full-featured testing framework for Golang

Testza is a full-featured testing framework for Go. It integrates with the default test runner, so you can use it with the standard go test tool. Testza contains easy-to-use methods like assertions, output capturing, fuzzing, and more.

The main goal of testza is to provide an easy and fun experience in writing tests and providing a nice, user-friendly output. Even developers who never used testza, will get into it quickly.

star Features

AssertionsAssertions allow you to check objects for expected values quickly.
FuzzingFuzzing allows you to check functions against sets of generated input parameters.
A couple lines of test code can run thousands of sanity tests.
Output CaptureCapture and validate output written to the terminal.
Perfect for CLI tools.
SnapshotsSnapshot objects between test runs, to ensure consistent behavior.
Clean OutputClean and colorful output provides you the needed details in an easy-to-understand format.
System InformationTestza prints information about the system on startup.
You can quickly figure out what’s wrong, when a user submits an issue.
Well DocumentedEvery function of testza is well documented and contains an example to make usage super easy.
CustomizableTestza features customizable settings if you want to change something.
Test flagsYou can configure testza via flags too!
That makes it super simple to change test runs, or output, without touching code!

rocket Getting Started with the Golang test framework

See the examples below for a quick introduction!

// --- Some Examples ---

// - Some assertions -
testza.AssertTrue(t, true) // -> Pass
testza.AssertNoError(t, err) // -> Pass
testza.AssertEqual(t, object, object) // -> Pass
// ...

// - Testing console output -
// Test the output of your CLI tool easily!
terminalOutput, _ := testza.CaptureStdout(func(w io.Writer) error {fmt.Println("Hello"); return nil})
testza.AssertEqual(t, terminalOutput, "Hello\n") // -> Pass

// - Fuzzing -
// Testing a function that accepts email addresses as a parameter:

// Testset of many different email addresses
emailAddresses := testza.FuzzStringEmailAddresses()

// Run a test for every string in the test set
testza.FuzzStringRunTests(t, emailAddresses, func(t *testing.T, index int, str string) {
  user, domain, err := internal.ParseEmailAddress(str) // Use your function
  testza.AssertNoError(t, err) // Assert that your function does not return an error
  testza.AssertNotZero(t, user) // Assert that the user is returned
  testza.AssertNotZero(t, domain) // Assert that the domain is returned

// And that's just a few examples of what you can do with Testza!

Project Documentation