Categorygithub.com/brian14708/testexec
repositorypackage
0.0.0-20240805133414-64c3d24fca81
Repository: https://github.com/brian14708/testexec.git
Documentation: pkg.go.dev

# README

testexec

Go Report Card Go Reference

Run subprocess tests for Go.

How to use

Setup code:

func TestMain(m *testing.M) {
	testexec.Main(m)
}

Add subprocess program:

var flagProgram = testexec.NewProgram(func(t *testexec.T, in int, out *int) {
	var f = flag.Int("data", 1, "")
	flag.Parse()
	*out = in + *f
})

Add test:

func TestFlag(t *testing.T) {
	var i int
	testexec.Run(t, flagProgram, 12, &i, "--data=123")
	assert.Equal(t, 135, i)
}