https://github.com/bayashi/witness
A test helper to make an evident report on a fail of your test.
https://github.com/bayashi/witness
deprecated deprecated-repository
Last synced: 4 months ago
JSON representation
A test helper to make an evident report on a fail of your test.
- Host: GitHub
- URL: https://github.com/bayashi/witness
- Owner: bayashi
- License: mit
- Archived: true
- Created: 2023-12-05T10:00:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-31T08:26:54.000Z (5 months ago)
- Last Synced: 2025-01-31T07:41:35.292Z (4 months ago)
- Topics: deprecated, deprecated-repository
- Language: Go
- Homepage:
- Size: 85.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [DEPRECATED] witness
This library was deprecated. It's included in [actually](https://github.com/bayashi/actually) now. The `witness` is no longer maintained. It will be removed from github.
`witness` is a test helper to make an evident report on a fail of your test.
## Usage
Simple case.
```go
package mainimport (
"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:
```go
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.
```go
w.Got(g).Expect(e).Fail(t, "Not same")
```There are switches to show more additional info:
```go
w.Got(g).Expect(e).ShowAll().Fail(t, "Not same")
```And then,
```go
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
---
```## Installation
```cmd
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