MCPcopy Index your code
hub / github.com/MarvinJWendt/testza

github.com/MarvinJWendt/testza @v0.5.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.5.2 ↗ · + Follow
314 symbols 1,232 edges 24 files 113 documented · 36% 2 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

testza 🍕

Testza is like pizza for Go - you could live without it, but why should you?

Latest Release

Tests

Coverage

Unit test count

Go Reference

Go report


Get The Module | Documentation | Contributing | Code of Conduct


Screenshot of an example test message

Join us on Discord!

Join us on Discord for support, discussions, updates and general talk!

📦 Installation

# Execute this command inside your project
go get github.com/MarvinJWendt/testza

📝 Description

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 much more.

The main goal of testza is to provide an easy and fun experience 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 quickly check objects for expected values.
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 a consistent behaviour. | | 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

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!

📚 Documentation

Module Methods
Settings Click to expand - [SetColorsEnabled](https://github.com/MarvinJWendt/testza#SetColorsEnabled) - [SetDiffContextLines](https://github.com/MarvinJWendt/testza#SetDiffContextLines) - [SetLineNumbersEnabled](https://github.com/MarvinJWendt/testza#SetLineNumbersEnabled) - [SetRandomSeed](https://github.com/MarvinJWendt/testza#SetRandomSeed) - [SetShowStartupMessage](https://github.com/MarvinJWendt/testza#SetShowStartupMessage)
Assert Click to expand - [AssertCompletesIn](https://github.com/MarvinJWendt/testza#AssertCompletesIn) - [AssertContains](https://github.com/MarvinJWendt/testza#AssertContains) - [AssertDecreasing](https://github.com/MarvinJWendt/testza#AssertDecreasing) - [AssertDirEmpty](https://github.com/MarvinJWendt/testza#AssertDirEmpty) - [AssertDirExists](https://github.com/MarvinJWendt/testza#AssertDirExists) - [AssertDirNotEmpty](https://github.com/MarvinJWendt/testza#AssertDirNotEmpty) - [AssertEqual](https://github.com/MarvinJWendt/testza#AssertEqual) - [AssertEqualValues](https://github.com/MarvinJWendt/testza#AssertEqualValues) - [AssertErrorIs](https://github.com/MarvinJWendt/testza#AssertErrorIs) - [AssertFalse](https://github.com/MarvinJWendt/testza#AssertFalse) - [AssertFileExists](https://github.com/MarvinJWendt/testza#AssertFileExists) - [AssertGreater](https://github.com/MarvinJWendt/testza#AssertGreater) - [AssertGreaterOrEqual](https://github.com/MarvinJWendt/testza#AssertGreaterOrEqual) - [AssertImplements](https://github.com/MarvinJWendt/testza#AssertImplements) - [AssertInRange](https://github.com/MarvinJWendt/testza#AssertInRange) - [AssertIncreasing](https://github.com/MarvinJWendt/testza#AssertIncreasing) - [AssertKindOf](https://github.com/MarvinJWendt/testza#AssertKindOf) - [AssertLen](https://github.com/MarvinJWendt/testza#AssertLen) - [AssertLess](https://github.com/MarvinJWendt/testza#AssertLess) - [AssertLessOrEqual](https://github.com/MarvinJWendt/testza#AssertLessOrEqual) - [AssertNil](https://github.com/MarvinJWendt/testza#AssertNil) - [AssertNoDirExists](https://github.com/MarvinJWendt/testza#AssertNoDirExists) - [AssertNoError](https://github.com/MarvinJWendt/testza#AssertNoError) - [AssertNoFileExists](https://github.com/MarvinJWendt/testza#AssertNoFileExists) - [AssertNoSubset](https://github.com/MarvinJWendt/testza#AssertNoSubset) - [AssertNotCompletesIn](https://github.com/MarvinJWendt/testza#AssertNotCompletesIn) - [AssertNotContains](https://github.com/MarvinJWendt/testza#AssertNotContains) - [AssertNotEqual](https://github.com/MarvinJWendt/testza#AssertNotEqual) - [AssertNotEqualValues](https://github.com/MarvinJWendt/testza#AssertNotEqualValues) - [AssertNotErrorIs](https://github.com/MarvinJWendt/testza#AssertNotErrorIs) - [AssertNotImplements](https://github.com/MarvinJWendt/testza#AssertNotImplements) - [AssertNotInRange](https://github.com/MarvinJWendt/testza#AssertNotInRange) - [AssertNotKindOf](https://github.com/MarvinJWendt/testza#AssertNotKindOf) - [AssertNotNil](https://github.com/MarvinJWendt/testza#AssertNotNil) - [AssertNotNumeric](https://github.com/MarvinJWendt/testza#AssertNotNumeric) - [AssertNotPanics](https://github.com/MarvinJWendt/testza#AssertNotPanics) - [AssertNotRegexp](https://github.com/MarvinJWendt/testza#AssertNotRegexp) - [AssertNotSameElements](https://github.com/MarvinJWendt/testza#AssertNotSameElements) - [AssertNotUnique](https://github.com/MarvinJWendt/testza#AssertNotUnique) - [AssertNotZero](https://github.com/MarvinJWendt/testza#AssertNotZero) - [AssertNumeric](https://github.com/MarvinJWendt/testza#AssertNumeric) - [AssertPanics](https://github.com/MarvinJWendt/testza#AssertPanics) - [AssertRegexp](https://github.com/MarvinJWendt/testza#AssertRegexp) - [AssertSameElements](https://github.com/MarvinJWendt/testza#AssertSameElements) - [AssertSubset](https://github.com/MarvinJWendt/testza#AssertSubset) - [AssertTestFails](https://github.com/MarvinJWendt/testza#AssertTestFails) - [AssertTrue](https://github.com/MarvinJWendt/testza#AssertTrue) - [AssertUnique](https://github.com/MarvinJWendt/testza#AssertUnique) - [AssertZero](https://github.com/MarvinJWendt/testza#AssertZero)
Capture Click to expand - [CaptureStderr](https://github.com/MarvinJWendt/testza#CaptureStderr) - [CaptureStdout](https://github.com/MarvinJWendt/testza#CaptureStdout) - [CaptureStdoutAndStderr](https://github.com/MarvinJWendt/testza#CaptureStdoutAndStderr)
Fuzz Utils Click to expand - [FuzzUtilDistinctSet](https://github.com/MarvinJWendt/testza#FuzzUtilDistinctSet) - [FuzzUtilLimitSet](https://github.com/MarvinJWendt/testza#FuzzUtilLimitSet) - [FuzzUtilMergeSets](https://github.com/MarvinJWendt/testza#FuzzUtilMergeSets) - [FuzzUtilModifySet](https://github.com/MarvinJWendt/testza#FuzzUtilModifySet) - [FuzzUtilRunTests](https://github.com/MarvinJWendt/testza#FuzzUtilRunTests)
Fuzz Booleans Click to expand - [FuzzBoolFull](https://github.com/MarvinJWendt/testza#FuzzBoolFull)
Fuzz Strings Click to expand - [FuzzStringEmailAddresses](https://github.com/MarvinJWendt/testza#FuzzStringEmailAddresses) - [FuzzStringEmpty](https://github.com/MarvinJWendt/testza#FuzzStringEmpty) - [FuzzStringFull](https://github.com/MarvinJWendt/testza#FuzzStringFull) - [FuzzStringGenerateRandom](https://github.com/MarvinJWendt/testza#FuzzStringGenerateRandom) - [FuzzStringHtmlTags](https://github.com/MarvinJWendt/testza#FuzzStringHtmlTags) - [FuzzStringLong](https://github.com/MarvinJWendt/testza#FuzzStringLong) - [FuzzStringNumeric](https://github.com/MarvinJWendt/testza#FuzzStringNumeric) - [FuzzStringUsernames](https://github.com/MarvinJWendt/testza#FuzzStringUsernames)
Fuzz Float64s Click to expand - [FuzzFloat64Full](https://github.com/MarvinJWendt/testza#FuzzFloat64Full) - [FuzzFloat64GenerateRandomNegative](https://github.com/MarvinJWendt/testza#FuzzFloat64GenerateRandomNegative) - [FuzzFloat64GenerateRandomPositive](https://github.com/MarvinJWendt/testza#FuzzFloat64GenerateRandomPositive) - [FuzzFloat64GenerateRandomRange](https://github.com/MarvinJWendt/testza#FuzzFloat64GenerateRandomRange)
Fuzz Integers Click to expand - [FuzzIntFull](https://github.com/MarvinJWendt/testza#FuzzIntFull) - [FuzzIntGenerateRandomNegative](https://github.com/MarvinJWendt/testza#FuzzIntGenerateRandomNegative) - [FuzzIntGenerateRandomPositive](https://github.com/MarvinJWendt/testza#FuzzIntGenerateRandomPositive) - [FuzzIntGenerateRandomRange](https://github.com/MarvinJWendt/testza#FuzzIntGenerateRandomRange)
Snapshot

Extension points exported contracts — how you extend this code

TestingPackageWithFailFunctions (Interface)
TestingPackageWithFailFunctions contains every function that fails a test in testing.T. [1 implementers]
utils.go

Core symbols most depended-on inside this repo

AssertTestFails
called by 86
assert.go
Fail
called by 63
internal/fail-printer.go
Helper
called by 60
internal/utils.go
AssertEqual
called by 42
assert.go
NewObjectsSingleNamed
called by 37
internal/fail-printer.go
AssertNoError
called by 32
assert.go
Errorf
called by 28
utils.go
FuzzUtilRunTests
called by 16
fuzz-utils.go

Shape

Function 267
Method 28
Struct 12
Interface 6
TypeAlias 1

Languages

Go100%

Modules by API surface

assert_test.go113 symbols
assert.go57 symbols
fuzz_test.go22 symbols
utils.go13 symbols
snapshot_test.go12 symbols
configuration.go11 symbols
internal/fail-printer.go10 symbols
internal/assertion_helper.go10 symbols
ci/main.go10 symbols
internal/difference.go8 symbols
fuzz-strings.go8 symbols
internal/utils.go7 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add testza \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page