Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor unit tests to not use Ginkgo #153

Open
anik120 opened this issue Aug 30, 2023 · 3 comments
Open

Refactor unit tests to not use Ginkgo #153

anik120 opened this issue Aug 30, 2023 · 3 comments
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Comments

@anik120
Copy link
Collaborator

anik120 commented Aug 30, 2023

Learned that @joelanford and @ncdc are of the opinion that using ginkgo for unit tests is introducing unnecessary complexity, which @stevekuznetsov has alluded to here too.

@ncdc
Copy link
Member

ncdc commented Aug 30, 2023

Using ginkgo for anything introduces too much complexity 😄

@ncdc
Copy link
Member

ncdc commented Aug 30, 2023

At least, it does for me. I have always struggled to understand when to use BeforeEach, JustBeforeEach, Describe, When, It, etc. Maybe if everyone is an expert in it, it provides a lot of value, but when you're not, it's super confusing. I prefer plain go tests, table driven when it makes sense, with testify and cmp.Diff.

@stevekuznetsov
Copy link
Member

I think many, many years have passed since there was a compelling technical reason to use Ginkgo. In the very early days, sub-tests did not exist and parallelism was harder to mange in Go standard library testing, so Ginkgo had some advantages. Today, not so much.

If you prefer BDD-style assertions, the testify package Andy mentions gets you everything you need without adding on a bunch of onerous expectations like Gomega does, or inflating the number of ways to do something - Gomega suffers from a lot of cases where thirteen different assertions are almost entirely identical, except for that one case, blah blah.

cmp.Diff() is a great option for test assertions since it pushes you to do a couple things:

  1. compare static structures, which means your tests use local object literals or golden files, which are easy to inspect and not interrelated between cases
  2. only compare public members of objects by default
  3. explicitly write comparators for cases where you want specific behavior

@everettraven everettraven added good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.
Projects
None yet
Development

No branches or pull requests

4 participants