Bifurcation Framework for testing and use cases

coverage badge GoDoc

Biff stands for BIFurcation Framework based on nesting cases or alternatives. You can take advantage of variable scoping to make your tests simpler and easier to read. Good choice for acceptance and use cases testing, it provides a BBD style exit.

Getting started

biff.Alternative("Instance service", func(a *biff.A) {

	s := NewMyService()

	a.Alternative("Register user", func(a *biff.A) {

		john := s.RegisterUser("[email protected]", "john-123")
		a.AssertNotNil(john)

		a.Alternative("Bad credentials", func(a *biff.A) {
			user := s.Login(john.Email, "bad-password")
			a.AssertNil(user)

		}).Alternative("Login", func(a *biff.A) {
			user := s.Login(john.Email, john.Password)
			a.AssertEqual(user, john)
		})

	})
})

Output:

=== RUN   TestExample
Case: Instance service
Case: Register user
    john is &example.User{Email:"[email protected]", Password:"john-123"}
Case: Bad credentials
    user is <nil>
-------------------------------
Case: Instance service
Case: Register user
    john is &example.User{Email:"[email protected]", Password:"john-123"}
Case: Login
    user is &example.User{Email:"[email protected]", Password:"john-123"}
-------------------------------
Case: Instance service
Case: Register user
    john is &example.User{Email:"[email protected]", Password:"john-123"}
-------------------------------
Case: Instance service
-------------------------------
--- PASS: TestExample (0.00s)
PASS

Get into the buggy line

In case of error, Biff will print something like this:

Case: Instance service
Case: Register user
    john is &example.User{Email:"[email protected]", Password:"john-123"}
Case: Login
    Expected: &example.User{Email:"[email protected]", Password:"1234"}
    Obtained: &example.User{Email:"[email protected]", Password:"john-123"}
    at biff/example.TestExample.func1.1.2(0xc420096ac0
    /home/fulldump/workspace/my-project/src/example/users_test.go:84 +0x12

Navigating directly to the line where the fail was produced.

Isolated use cases

All possible bifurcations are tested in an isolated way.

BDD on the fly

You do not need to translate your tests behaviour to natural language. Biff will navigate through the execution stack and will parse portions of your testing code to pretty print your assertions.

This testing code:

a.AssertEqual(user, john)

will be printed as:

    user is &example.User{Email:"[email protected]", Password:"john-123"}

Take advantage of go function scope

Avoid testing helpers and auxiliar methods to maintain the status between tests, take advantage of language varialbe scope itself to write powerful tests easy to write and easy to read.

Supported assertions

Most commonly used assertions are implemented:

  • AssertEqual
  • AssertEqualJson
  • AssertNil
  • AssertNotNil
  • AssertNotEqual
  • AssertInArray
  • AssertTrue
  • AssertFalse

Contribute

Feel free to fork, make changes and pull-request to master branch.

If you prefer, create a new issue or email me for new features, issues or whatever.

Testing

Who will test the tester? ha ha

There are no tests for the moment but there will be, sooner than later.

Example project

This project includes an example project with some naive business logic plus some Biff tests.

Similar Resources

A simple logging framework for Go program.

A simple logging framework for Go program.

ASLP A Go language based log library, simple, convenient and concise. Three modes, standard output, file mode and common mode. Convenient, simple and

Nov 14, 2022

Benchmore - A package allows you to report On-CPU Time in addition to the wall time measured by Go's builtin benchmarking framework

benchmore This package allows you to report On-CPU Time in addition to the wall

Feb 9, 2022

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.

The open-source platform for monitoring and observability. Grafana allows you to query, visualize, alert on and understand your metrics no matter wher

Jan 3, 2023

Gowl is a process management and process monitoring tool at once. An infinite worker pool gives you the ability to control the pool and processes and monitor their status.

Gowl is a process management and process monitoring tool at once. An infinite worker pool gives you the ability to control the pool and processes and monitor their status.

Gowl is a process management and process monitoring tool at once. An infinite worker pool gives you the ability to control the pool and processes and monitor their status.

Nov 10, 2022

Simple and configurable Logging in Go, with level, formatters and writers

go-log Logging package similar to log4j for the Golang. Support dynamic log level Support customized formatter TextFormatter JSONFormatter Support mul

Sep 26, 2022

A Go (golang) package providing high-performance asynchronous logging, message filtering by severity and category, and multiple message targets.

ozzo-log Other languages 简体中文 Русский Description ozzo-log is a Go package providing enhanced logging support for Go programs. It has the following fe

Dec 17, 2022

Library and program to parse and forward HAProxy logs

haminer Library and program to parse and forward HAProxy logs. Supported forwarder, Influxdb Requirements Go for building from source code git for dow

Aug 17, 2022

Cloudinsight Agent is a system tool that monitors system processes and services, and sends information back to your Cloudinsight account.

Cloudinsight Agent 中文版 README Cloudinsight Agent is written in Go for collecting metrics from the system it's running on, or from other services, and

Nov 3, 2022

Distributed simple and robust release management and monitoring system.

Distributed simple and robust release management and monitoring system.

Agente Distributed simple and robust release management and monitoring system. **This project on going work. Road map Core system First worker agent M

Nov 17, 2022
Tracetest - Trace-based testing. End-to-end tests powered by your OpenTelemetry Traces.
Tracetest - Trace-based testing. End-to-end tests powered by your OpenTelemetry Traces.

End-to-end tests powered by OpenTelemetry. For QA, Dev, & Ops. Live Demo | Documentation | Twitter | Discord | Blog Click on the image or this link to

Jan 3, 2023
Golog is a logger which support tracing and other custom behaviors out of the box. Blazing fast and simple to use.

GOLOG Golog is an opinionated Go logger with simple APIs and configurable behavior. Why another logger? Golog is designed to address mainly two issues

Oct 2, 2022
A feature-rich and easy to use logger for golang
A feature-rich and easy to use logger for golang

A feature-rich and easy to use logger for golang ?? Install ?? Common Logs lumber.Success() lumber.Info() lumber.Debug() lumber.Warning()

Dec 31, 2022
A simple to use log system, minimalist but with features for debugging and differentiation of messages
A simple to use log system, minimalist but with features for debugging and differentiation of messages

A simple to use log system, minimalist but with features for debugging and differentiation of messages

Sep 26, 2022
Open source framework for processing, monitoring, and alerting on time series data

Kapacitor Open source framework for processing, monitoring, and alerting on time series data Installation Kapacitor has two binaries: kapacitor – a CL

Dec 26, 2022
Very powerful server agent for collecting & sending logs & metrics with an easy-to-use web console.
Very powerful server agent for collecting & sending logs & metrics with an easy-to-use web console.

logkit-community 中文版 Introduce Very powerful server agent for collecting & sending logs & metrics with an easy-to-use web console. logkit-community De

Dec 29, 2022
Self-use log encapsulation for golang

package app import "github.com/restoflife/log" func Init() { log.Ne

Dec 29, 2021
The open telemetry framework
The open telemetry framework

DISCONTINUATION OF PROJECT This project will no longer be maintained by Intel. Intel will not provide or guarantee development of or support for this

Dec 27, 2022
Time Series Alerting Framework

Bosun Bosun is a time series alerting framework developed by Stack Exchange. Scollector is a metric collection agent. Learn more at bosun.org. Buildin

Dec 27, 2022
A CUE-based framework for portable, evolvable, schema

Scuemata Scuemata is a system for writing schemas. Like JSON Schema or OpenAPI, it is general-purpose, and most obviously useful as an IDL. Unlike JSO

Dec 24, 2022