Skip to content

Improve test suite descriptions #1157

@nventuro

Description

@nventuro

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueLow hanging fruit for new contributors to get involved!testsTest suite and helpers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions