GithubHelp home page GithubHelp logo

assizes's Introduction

Overview

The assizes library is a helper library for the standard Go testing package. It provides some basic assert functionality, allowing your Go tests to be less verbose. The assert style is patterned after Java's JUnit style.

Only a few helpers have been added so far - the ones I've needed for my tests. More will be added. Feel free to add your own.

The library name refers to the old British Courts of Assizes, which, being an American, I used to read and wonder about in my college days while reading lots of Dickens, Thackeray and George Eliot.

Install

go get github.com/quux00/assizes

Usage

Wrap the testing.T pointer in an Assize and then use the Assert methods on the Assize. Any errors will be reported as failing on the line you called the assert from.

import (
    az "github.com/quux00/assizes"
    "testing"
)

func TestQueue(t *testing.T) {
	a := az.Assize{t}

	q := NewQueue()
    a.AssertNotNil(q)
    a.AssertTrue(q.IsEmpty())
    a.AssertEqual(0, q.Size())

	q.Enqueue("a")
	q.Enqueue("b")
    
    a.AssertFalse(q.IsEmpty())
    var (
        v interface{}
        err error
    )
    v, err = q.Dequeue()
    a.AssertNil(err)
    a.AssertEqual("a", v)

    // &etc.
}

Failure messages look like:

--- FAIL: TestSize (0.00 seconds)
    assizes.go:36: assertEqual failed (line 30). exp: 1; act: 0

The API for AssertEquals is to pass in expected first and then actual. The line number in parens ("line 30" above) refers to the line from which you called the assert method.

LICENSE

Released under the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.