A lightweight dependency-free helper for writing golang tests.
No bells and whistles, just a very simple test helper that won't bring extra dependencies to your projects.
package calc
func Sum(value1, value2 int) int {
return value1 + value2
}
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)
}
This application is licensed under the MIT License, you may obtain a copy of it here.