GithubHelp home page GithubHelp logo

bayashi / witness Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 80 KB

A test helper to make an evident report on a fail of your test.

License: MIT License

Go 100.00%
golang testing go golang-testing

witness's Introduction

witness

witness CI witness report card Go Reference: witness

witness is a test helper to make an evident report on a fail of your test.

Usage

Simple case.

package main

import (
    "testing"

    w "github.com/bayashi/witness"
)

func TestExample(t *testing.T) {
    g := "a\nb\nc"
    e := "a\nd\nc"

    if g != e {
        w.Fail(t, "Not same", g, e)
    }
}

below result will be shown:

Test name:      TestExample
Trace:          /home/usr/go/src/github.com/bayashi/witness/witness_test.go:14
Fail reason:    Not same
Type:           Expect:string, Got:string
Expected:       "a\nd\nc"
Actually got:   "a\nb\nc"

There is a builder interface to specify waht you report.

w.Got(g).Expect(e).Fail(t, "Not same")

There are switches to show more additional info:

w.Got(g).Expect(e).ShowAll().Fail(t, "Not same")

And then,

Test name:      TestExample
Trace:          /home/usr/go/src/github.com/bayashi/witness/witness_test.go:14
Fail reason:    Not same
Type:           Expect:string, Got:string
Expected:       "a\nd\nc"
Actually got:   "a\nb\nc"
Diff details:   --- Expected
                +++ Actually got
                @@ -1,3 +1,3 @@
                 a
                -d
                +b
                 c
Raw Expect:     ---
                a
                d
                c
                ---
Raw Got:        ---
                a
                b
                c
                ---

See witness-showcase for actual outputs on fail.

Also see Witness Package reference for more details.

Installation

go get github.com/bayashi/witness

License

MIT License

Author

Dai Okabayashi: https://github.com/bayashi

See Also

https://github.com/bayashi/actually

Special Thanks To

https://github.com/stretchr/testify

witness's People

Contributors

bayashi avatar dependabot[bot] avatar

Watchers

 avatar  avatar

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.