brian14708 / testexec

Run subprocess tests for Go.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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)
}

About

Run subprocess tests for Go.

License:MIT License


Languages

Language:Go 100.0%