
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.
Features
| Feature | Description |
|---|---|
| Assertions | Assertions allow you to check objects for expected values quickly. |
| Fuzzing | Fuzzing allows you to check functions against sets of generated input parameters. A couple lines of test code can run thousands of sanity tests. |
| Output Capture | Capture and validate output written to the terminal. Perfect for CLI tools. |
| Snapshots | Snapshot objects between test runs, to ensure consistent behavior. |
| Clean Output | Clean and colorful output provides you the needed details in an easy-to-understand format. |
| System Information | Testza prints information about the system on startup. You can quickly figure out what’s wrong, when a user submits an issue. |
| Well Documented | Every function of testza is well documented and contains an example to make usage super easy. |
| Customizable | Testza features customizable settings if you want to change something. |
| Test flags | You can configure testza via flags too! That makes it super simple to change test runs, or output, without touching code! |
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
There is no ads to display, Please add some
