Skip to content

corbym/jsonspec

Repository files navigation

jsonspec

Build status GoDoc Go Report Card

JSON output generator for the BDD framework GoGiven

Import:

import github.com/corbym/jsonspec

Usage:

package foo
import (
	"testing"
	"github.com/corbym/gogiven"
	"github.com/corbym/jsonspec"
	"os"
)

func TestMain(testmain *testing.M) {
	gogiven.Generator = jsonspec.NewTestOutputGenerator()
	runOutput := testmain.Run()
	gogiven.GenerateTestOutput()
	os.Exit(runOutput)
}

... actual tests...

Example Output

{
	"title": "Clock Test",
	"test_state": {
		"github.com/corbym/berlinclock_test.TestGivenAClockWhenTimeIsEnteredThenCorrectClock": {
			"test_results": {
				"id": "github.com/corbym/berlinclock_test.TestGivenAClockWhenTimeIsEnteredThenCorrectClock",
				"failed": false,
				"skipped": false,
				"test_output": ""
			},
			"test_title": "Given A Clock When Time Is Entered Then Correct Clock",
			"interesting_givens": {
				"expected": "YOOOOOOOOOOOOOOOOOOOOOOO",
				"time": "00:00:00"
			},
			"captured_io": {},
			"given_when_then": [
				"Given testing clock parameters under test",
				"When",
				"Clock err = berlinclock clock test time",
				"Then",
				"Then assert that testing err is nil",
				"Then assert that testing clock is",
				"Equal to test expected",
				"Reasonf \"time incorrect for % s\" test time"
			]
		}
	}
}