Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.
/ go-test Public archive

A lightweight dependency-free helper for writing golang tests.

License

Notifications You must be signed in to change notification settings

pjbgf-archives/go-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-test

A lightweight dependency-free helper for writing golang tests.

codecov GoReport GoDoc build MIT License

No bells and whistles, just a very simple test helper that won't bring extra dependencies to your projects.

Sample Code

package calc

func Sum(value1, value2 int) int {
	return value1 + value2
}

Testing the Sample Code

package calc

import (
	"testing"

	"github.com/pjbgf/go-test/should"
)

func TestSum(t *testing.T) {
	assertThat := func(assumption string, value1, value2, expected int) {
		should := should.New(t)

		actual := Sum(value1, value2)

		should.BeEqual(expected, actual, assumption)
	}

	assertThat("should return 13 for 4 and 9", 4, 9, 13)
	assertThat("should return 50 for 15 and 30", 15, 35, 50)
}

License

This application is licensed under the MIT License, you may obtain a copy of it here.