assertions

package module
v0.0.0-...-bdead44 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

Assertions Repository

This repository exposes some useful methods for unit testing in Go. Defines methods to do "assertions" on your tests to have more consice tests files.

Assertions

Assert

Asserts if the given condition is true.

func TestExampleOfUse(t *Testing.T) {
  Assertions.Assert(t, 3 == 3, "3 is equals to 3")
  Assertions.Assert(t, 3 == 0, "3 is equals to 0")
}
// Tests will fail with: "caller.go:10: Condition '3 is equals to 0' not met: expected 'true' given 'false'"

AssertEquals

Asserts if the given values expected and given are equals.

func TestExampleOfUse(t *Testing.T) {
  Assertions.Assert(t, 3, 3, "3 is equals to 3")
  Assertions.Assert(t, 3, 0, "3 is equals to 0")
}
// Tests will fail with: "caller.go:10: Condition '3 is equals to 0' not met: expected '3' given '0'"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(t testing.TB, condition bool, description string)

func AssertEquals

func AssertEquals(t testing.TB, expected any, given any, description string)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL