You don't need testify/assert (Golang)

a year ago by cm0002 to c/golang

To have expressive test assertions.
MrTrono 6 points a year ago

We don't need testify... proceeds to write testify

path: 0 18275827, hotness: undefined, score: 6, children: 3
sxan -1 points a year ago

For many cases, writing assert is both trivial and effective, and prevents importing yet another fairly large dependency.

A little copying is better than a little dependency.

  • Rob Pike
path: 0 18275827 18282357, hotness: undefined, score: -1, children: 2
MrTrono 1 point a year ago
  1. it is a test dependency
  2. wouldn't go tree shaking make any size concern moot.

I'm not agreeing that you do or don't need testify, but find the argument against testify that is presented here incredibly weak. Ultimately if you're wasting any time thinking about an asset library you're doing it wrong.

path: 0 18275827 18282357 18298033, hotness: undefined, score: 1, children: 1
sxan 0 points a year ago

It's not a dependency, though. I mean, it could be, but you can just ssd easily rewrite or copy/paste; his repos is basically a single for with a half dozen functions. It's a hundred LOC, or something. Copy the file, change the package. A little copying.

I usually just re-implement the asserts as I need them, but copying this one for over into your project introduces no dependencies. If you import testify, you now have dependencies on

  • testify
  • github.com/davecgh/go-spew
  • github.com/pmezard/go-difflib
  • github.com/stretchr/objx
  • gopkg.in/yaml.v3

because that's what testify imports.

It's not the same, at all.

path: 0 18275827 18282357 18298033 18299704, hotness: undefined, score: 0, children: 0
golang
golang

@programming.dev

login for more options
2783
317
26

This is a community dedicated to the go programming language.

Useful Links:

Rules:

  • Posts must be relevant to Go
  • No NSFW content
  • No hate speech, bigotry, etc
  • Try to keep discussions on topic
  • No spam of tools/companies/advertisements
  • It’s OK to post your own stuff part of the time, but the primary use of the community should not be self-promotion.

go to feed...