brokkr

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: MIT Imports: 11 Imported by: 0

README

Brokkr

Coverage GitHub Super-Linter

Brokkr micro framework that helps you quickly write simple API's

BDD tester

Brokkr contians a component that helps you easily set up BDD testing of your API.

Write test cases

Write your BDD test cases using cucumber/godog in plain text.

Feature: myFeature

  Scenario: Passing Test
    Given This test will pass
Initialization
func TestMain(m *testing.M) {
	bddTester := bdd.NewBDDTester("BDD tests of MyService")

	bddTester.AddScenario(bdd.Scenario{
		Expr:     `^This test will pass$`,
		StepFunc: testIsPassing,
	})

	status := bddTester.RunTests()
	if st := m.Run(); st > status {
		status = st
	}

	os.Exit(status)
}

func testIsPassing() error {
	return nil
}

You can read more about GoDog here: https://github.com/cucumber/godog

Use prepared stepFuncs from ActorAPI

You don't have to create all your step functions from scratch. Initialize ActorAPI and use the pre-made step functions. The ActorAPI package contains a number of generic functions to help you make requests and analyze responses.

func TestMain(m *testing.M) {
	bddTester := bdd.NewBDDTester("BDD tests of MyService")
	
	a := tester.NewActorAPI()

	bddTester.AddScenario(bdd.Scenario{
		Expr:     `^I send "([^"]*)" request to "([^"]*)" with payload "([^"]*)"$`,
		StepFunc: a.ISendRequestWithPayload,
	})

	status := bddTester.RunTests()
	if st := m.Run(); st > status {
		status = st
	}

	os.Exit(status)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Brokkr

type Brokkr struct {
	// contains filtered or unexported fields
}

Brokkr core loop system of the app

func NewBrokkr

func NewBrokkr(opts ...Options) (b *Brokkr)

NewBrokkr framework instance

func (*Brokkr) Start

func (c *Brokkr) Start() error

Start main loop and call callback in the end

func (*Brokkr) Stop

func (c *Brokkr) Stop() error

Stop in graceful mode

type Options

type Options func(o *Brokkr)

Options sets of configurations for Brokkr

func AddBackgroundTasks

func AddBackgroundTasks(bt ...background.Process) Options

AddBackgroundTasks that will be executed in background of main loop

func SetForceStopTimeout

func SetForceStopTimeout(t time.Duration) Options

SetForceStopTimeout redefines force shutdown timeout

Jump to

Keyboard shortcuts

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