Skip to content

coopernurse/statespec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

statespec

Stateful generative testing for Go

Requirements

statespec uses Go 1.18 generics and will not work with older Go versions.

Overview

This package provides a way to test a system via a set of properties (called Commands) that each interact with the system under test and optionally track state that has modified in the system.

Commands are composed into a Spec and Spec.Run will run the spec a number of times, randomly choosing commands in the spec to run.

Example

Real World API

Real World is a project that defines an OpenAPI specification for a fictional web service. Various people have written UI clients against this spec and backend implementations of the spec.

We can use statespec to test a Real World backend.

# Start a separate terminal
#
# Clone a Go implementation - not affiliated with this project
git clone https://github.com/xesina/golang-echo-realworld-example-app.git

# Start the server - this runs on localhost:8585 and will write data to a file using sqlite3
cd golang-echo-realworld-example-app
go run main.go

In another terminal run the test

cd statespec
go run examples/realworldapi/realworldapi.go -n 10

About

stateful generative testing for Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages