Categorygithub.com/jcdotter/gtest
repositorypackage
0.0.3
Repository: https://github.com/jcdotter/gtest.git
Documentation: pkg.go.dev

# README

GTEST

gtest extends the Stretcher Testify package
(reference https://github.com/stretchr/testify/blob/master/README.md)


gtest 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 gtest, use go get:

go get github.com/jcdotter/gtest

or include the github.com/jcdotter/gtest 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/gtest"
)

func TestYourCode(t *testing.T) {

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

}

Configuration

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

Step 1. Create a new test_file.go

package your_package

import (
    "testing"
    "github.com/jcdotter/gtest"
)

func TestYourCode(t *testing.T) {

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

    gt := gtest.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 gtest to the latest version, use

go get -u github.com/jcdotter/gtest

Supported go versions

We currently support the most recent major Go versions from 1.19 onward.


License

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