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

Improve test suite descriptions #1157

Closed
nventuro opened this issue Aug 6, 2018 · 3 comments · Fixed by #2334
Closed

Improve test suite descriptions #1157

nventuro opened this issue Aug 6, 2018 · 3 comments · Fixed by #2334
Labels
good first issue Low hanging fruit for new contributors to get involved! tests Test suite and helpers.

Comments

@nventuro
Copy link
Contributor

nventuro commented Aug 6, 2018

The description of each tests (i.e. the text in the describe, context and it blocks) is a bit inconsistent, we should move towards a more standard structure.

I suggest:

  • contract()
  • describe(<feature/function>)
  • context(<context (!), e.g: once deployed, in refund period, when disabled, etc>)
  • it(<verb in present simple, e.g. 'accepts payments', 'allows owner to transfer ownership' // avoid using 'should do x', go for 'does x' instead>)
    • Describe what you're testing, not what you're trying to prove: e.g. if testing a transaction fails from a non-owner account, write 'rejects non owners', instead of 'requires an owner account'.
    • Use the terms 'null address' for address 0, 'zero-valued' for txs that don't transfer ether, and 'null [role]' for a role assigned to the null address (e.g. 'allows setting a null owner')

This will allow us to write test chains that read very naturally, e.g.
PausableToken transfer when paused reverts

@nventuro nventuro added good first issue Low hanging fruit for new contributors to get involved! kind:improvement tests Test suite and helpers. labels Aug 6, 2018
@frangio
Copy link
Contributor

frangio commented Aug 8, 2018

I like the proposal!

@singhj1234
Copy link

Hi, I want to help improve test descriptions. Can I change a few then submit a pull request so it can be reviewed. I saw what was done in #1204 , #1195 and #1237 so I have an idea of what changes need to be done.

@nventuro
Copy link
Contributor Author

@singhj1234 please do! I haven't been tackling this due to prioritizing other tasks, but these definitely need some love.

@nventuro nventuro removed this from the Test helpers milestone Mar 8, 2019
dibi91 added a commit to dibi91/openzeppelin-contracts that referenced this issue Aug 25, 2020
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
dibi91 added a commit to dibi91/openzeppelin-contracts that referenced this issue Aug 25, 2020
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
dibi91 added a commit to dibi91/openzeppelin-contracts that referenced this issue Aug 25, 2020
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
frangio added a commit that referenced this issue Aug 25, 2020
Co-authored-by: Paolo Dibitonto <p.dibitonto@almaviva.it>
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Low hanging fruit for new contributors to get involved! tests Test suite and helpers.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants