package
0.1.2
Repository: https://github.com/jcdotter/go.git
Documentation: pkg.go.dev

# README

GOTEST

gotest is a simple test assertion package\


gotest provides clear readouts of tests performed set by the Configurations:

  • PrintTest prints the expected and actual output of every test
  • PrintFail prints the expected and actual output when a test fails
  • PrintTrace prints the location of the test in the test file
  • Truncate limits the data printed to console

Getting Started:

  • Install gtest with go get
  • Use our example to see how to run your first gotest


Installation

To install gotest, use go get:

go get github.com/jcdotter/go/test

or include the github.com/jcdotter/go/test package as an import in your test file and run:

go mod tidy

Use this template in your code to get started with your first basic test:

package your_package

import (
    "testing"
    gt "github.com/jcdotter/go/test"
)

func TestYourCode(t *testing.T) {

    gt.True(t, true, "True is true!")

}

Configuration

Configure the settings for the tester using the test.Config struct

Step 1. Create a new test_file.go

package your_package

import (
    "testing"
    "github.com/jcdotter/go/test"
)

func TestYourCode(t *testing.T) {

    config := &test.Config{
        PrintTest: true,
        PrintTrace: true,
        PrintDetail: true,
        Msg: "result: %s",
    }

    gt := test.New(t, config)

    gt.True(true, "true is true!")

}

Step 2. Run the test in your terminal

$ go test -run TestYourCode

Step 3. Check your terminal output

#0 test 'True' succeeded: result: true is true!
  src:          test_file.TestYourCode line 18
  expected:     true
  actual:       true

Staying up to date

To update gotest to the latest version, use

go get -u github.com/jcdotter/go/test

Supported go versions

Currently supporting the most recent major Go versions from 1.19 onward.


License

This project is licensed under the terms of the MIT license.