Skip to content

cyolosecurity/bdd-meetup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Behavior-Driven Development (BDD) in Go

Welcome to the BDD in Go Integration Meetup! In this session, we'll explore how to implement BDD using Go, integrate with tools, and connect with other systems. This README contains resources and links to help you dive deeper into the topics we discussed.

Table of Contents

  1. Introduction to BDD
  2. BDD in Go: Key Concepts
  3. Tools for BDD in Go
  4. Orchestration and Infrastructure
  5. Further Reading

Introduction to BDD

Behavior-Driven Development (BDD) is an agile software development process that encourages collaboration between developers, testers, and non-technical or business participants in a software project.

For more information, you can check this BDD documentation:


BDD in Go: Key Concepts

BDD in Go can be implemented using several libraries and frameworks. We'll focus on the Godog framework, which integrates with Cucumber.

Here are some key concepts from our discussion:

Example from the meetup:

@sanity
Scenario: Worker wants to print a document
  Given: A workstation, a printer
  When: Worker clicks "print" button
  Then: Printer actually prints

Corresponding Go code example:

sc.Step(`^worker clicks \"(print|cancel)\" button$`, clickPerformed)

func clickPerformed(ctx context.Context, ...) (context.Context, error) {
    // your code logic
}

Tools for BDD in Go

Several tools can help integrate BDD into your Go projects. Below are the most popular ones we covered:


Orchestration and Infrastructure

In more complex testing environments, orchestration becomes crucial. During the meetup, we discussed how to dynamically build and run environments using runnable units and bundles. These abstractions allow you to simulate complex infrastructure setups needed for testing.

Runnable Units

  • A Runnable Unit represents a piece of infrastructure where tests are executed. This can be a Docker container, a database, or a mock service.
  • Each unit implements an interface with essential methods like Build, Start, and Remove.
    Example:
    type Runnable interface {
        Build() error
        Start() error
        Remove() error
        ID() string
        Status() (Status, error)
    }

Bundles

  • A Bundle is a collection of runnable units. The bundle ensures all units are ready before tests run. For example, starting a Docker container for each unit and checking its status.
    type Bundle interface {
        Add(r Runnable) error
        GetUnits() map[string]Runnable
        GetUnit(id string) (Runnable, bool)
        Remove(id string) error
    }

This modular approach allows you to:

  • Reuse bundles between runs for faster test execution.
  • Support specific use cases like zero-downtime upgrades by grouping infrastructure components.

Further Reading

Here are some additional resources that can help you master BDD and its implementation in Go:


License

MIT License


About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published