Documentation
¶
Index ¶
- func Debug(ctx context.Context) []io.Writer
- func Fixtures(ctx context.Context) map[string]gdttypes.Fixture
- func New(mods ...ContextModifier) context.Context
- func Plugins(ctx context.Context) []gdttypes.Plugin
- func PriorRun(ctx context.Context) map[string]interface{}
- func RegisterFixture(ctx context.Context, name string, f gdttypes.Fixture) context.Context
- func RegisterPlugin(ctx context.Context, p gdttypes.Plugin) context.Context
- func SetDebug(ctx context.Context, writers ...io.Writer) context.Context
- func StorePriorRun(ctx context.Context, data map[string]interface{}) context.Context
- func TimedOut(ctx context.Context, err error) bool
- type ContextKey
- type ContextModifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterFixture ¶
RegisterFixture registers a named fixtures with the context
func RegisterPlugin ¶
RegisterPlugin registers a plugin with the context
func SetDebug ¶
SetDebug sets gdt's debug logging to the supplied `io.Writer`.
The `writers` parameters is optional. If no `io.Writer` objects are supplied, gdt will output debug messages using the `testing.T.Log[f]()` function. This means that you will only get these debug messages if you call the `go test` tool with the `-v` option (either as `go test -v` or with `go test -v=test2json`.
func StorePriorRun ¶
StorePriorRun saves prior run data in the context. If there is already prior run data cached in the supplied context, the existing data is merged with the supplied data.
Types ¶
type ContextKey ¶
type ContextKey string
type ContextModifier ¶
ContextModifier sets some value on the context
func WithDebug ¶
func WithDebug(writers ...io.Writer) ContextModifier
WithDebug informs gdt to output extra debugging information. You can supply zero or more `io.Writer` objects to the function.
If no `io.Writer` objects are supplied, gdt will output debug messages using the `testing.T.Log[f]()` function. This means that you will only get these debug messages if you call the `go test` tool with the `-v` option (either as `go test -v` or with `go test -v=test2json`.
```go
func TestExample(t *testing.T) {
require := require.New(t)
fp := filepath.Join("testdata", "example.yaml")
f, err := os.Open(fp)
require.Nil(err)
ctx := gdtcontext.New(gdtcontext.WithDebug())
s, err := scenario.FromReader(
f,
scenario.WithPath(fp),
scenario.WithContext(ctx),
)
require.Nil(err)
require.NotNil(s)
err = s.Run(ctx, t)
require.Nil(err)
}
```
If you want gdt to log extra debugging information about tests and assertions to a different file or collecting buffer, pass it a context with a debug `io.Writer`:
```go f := ioutil.TempFile("", "mytest*.log") ctx := gdtcontext.New(gdtcontext.WithDebug(f)) ```
```go var b bytes.Buffer w := bufio.NewWriter(&b) ctx := gdtcontext.New(gdtcontext.WithDebug(w)) ```
you can then inspect the debug "log" and do whatever you'd like with it.
func WithFixtures ¶
func WithFixtures(fixtures map[string]gdttypes.Fixture) ContextModifier
WithFixtures sets a context's Fixtures
func WithPlugins ¶
func WithPlugins(plugins []gdttypes.Plugin) ContextModifier
WithPlugins sets a context's Plugins