Friday, May 17, 2024
HomeGolangA full-featured testing framework for Golang

A full-featured testing framework for Golang


Testza is a full-featured testing framework for Go. It integrates with the default check runner, so you need to use it with the usual go check device. Testza comprises easy-to-use strategies like assertions, output capturing, fuzzing, and extra.

The principle aim of testza is to supply a simple and enjoyable expertise in writing assessments and offering a pleasant, user-friendly output. Even builders who by no means used testza, will get into it rapidly.

star Options

Function Description
Assertions Assertions help you examine objects for anticipated values rapidly.
Fuzzing Fuzzing means that you can examine features in opposition to units of generated enter parameters.
A pair strains of check code can run hundreds of sanity assessments.
Output Seize Seize and validate output written to the terminal.
Excellent for CLI instruments.
Snapshots Snapshot objects between check runs, to make sure constant habits.
Clear Output Clear and colourful output supplies you the wanted particulars in an easy-to-understand format.
System Data Testza prints details about the system on startup.
You possibly can rapidly determine what’s mistaken, when a consumer submits a difficulty.
Properly Documented Each perform of testza is nicely documented and comprises an instance to make utilization tremendous simple.
Customizable Testza options customizable settings if you wish to change one thing.
Check flags You possibly can configure testza through flags too!
That makes it tremendous easy to vary check runs, or output, with out touching code!

rocket Getting Began with the Golang check framework

See the examples under for a fast introduction!

// --- Some Examples ---

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

// - Testing console output -
// Check the output of your CLI device simply!
terminalOutput, _ := testza.CaptureStdout(func(w io.Author) error {fmt.Println("Hey"); return nil})
testza.AssertEqual(t, terminalOutput, "Hellon") // -> Go

// - Fuzzing -
// Testing a perform that accepts electronic mail addresses as a parameter:

// Testset of many various electronic mail addresses
emailAddresses := testza.FuzzStringEmailAddresses()

// Run a check for each string within the check set
testza.FuzzStringRunTests(t, emailAddresses, func(t *testing.T, index int, str string) {
  consumer, area, err := inside.ParseEmailAddress(str) // Use your perform
  testza.AssertNoError(t, err) // Assert that your perform doesn't return an error
  testza.AssertNotZero(t, consumer) // Assert that the consumer is returned
  testza.AssertNotZero(t, area) // Assert that the area is returned
})

// And that is only a few examples of what you are able to do with Testza!

Undertaking Documentation

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments