jsonspec

package module
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2018 License: BSD-3-Clause Imports: 5 Imported by: 0

README

jsonspec

Build status GoDoc Go Report Card Coverage Status

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": "Generator Test",
  "test_state": {
    "test title": {
      "test_results": {
        "id": "abc2124",
        "failed": true,
        "skipped": true,
        "test_output": "well alrighty then"
      },
      "test_title": "test title",
      "interesting_givens": {
        "faff": "flap"
      },
      "captured_io": {
        "foob": "barb"
      },
      "given_when_then": {
        "given_when_then": [
          "given",
          "when",
          "then"
        ],
        "comment": [
          "Fooing is best",
          "done with friends"
        ]
      }
    }
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestOutputGenerator

type TestOutputGenerator struct {
	generator.GoGivensOutputGenerator
	MarshalJSON func(v interface{}) ([]byte, error)
}

TestOutputGenerator is an implementation of the GoGivensOutputGenerator that generates a JSON file per test. It is thread safe between goroutines.

func NewTestOutputGenerator

func NewTestOutputGenerator() *TestOutputGenerator

NewTestOutputGenerator creates a template that is used to generate the json output.

func (*TestOutputGenerator) ContentType added in v1.3.0

func (outputGenerator *TestOutputGenerator) ContentType() string

ContentType for the output generated.

func (*TestOutputGenerator) Generate

func (outputGenerator *TestOutputGenerator) Generate(pageData generator.PageData) io.Reader

Generate generates json output for a test. The return string contains the html that goes into the output file generated in gogivens.GenerateTestOutput(). The function panics if the template cannot be generated.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL