Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Documentation should cover usual testing patterns #64

Open
miohtama opened this issue Mar 29, 2020 · 3 comments
Open

Documentation should cover usual testing patterns #64

miohtama opened this issue Mar 29, 2020 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@miohtama
Copy link

miohtama commented Mar 29, 2020

Currently the test environment documentation does very good job to get started

https://docs.openzeppelin.com/test-environment/0.1/getting-started

However after that the developer path is lost and there is no information what methods to call, and how, to test your contracts. I would suggest to have the following often occuring test cases covered with their own small examples with a title and description

  • Using multiple different accounts in the tests (this is actual covered, but having a real life example how to name accounts with variable destructuring)
  • Reading contract values, address
  • Reading contract values, big num and asseting it against other big num (not that straightforward)
  • Calling a contract function, one parameter
  • Calling a contract function, multiple parameters
  • Asserting for tripped require()
  • Asserting that the contract emits correct events
  • Changing now - or time travelling
  • Using web3 utility functions

Some of these is goeverd covered in test-helpers API documentation., for some your mileage may vary. test-helper API documentation is very helpful if you an experience Ethereum, but the lack of full examples might be complicated for those who are still learning Ethereum concepts.

By a better developer experience, it is easier to attract more users for this wonderful library.

@miohtama miohtama changed the title Documentation should cover basic test cases Documentation should cover usual testing patterns Mar 29, 2020
@abcoathup abcoathup added the documentation Improvements or additions to documentation label Mar 31, 2020
@abcoathup
Copy link
Contributor

Hi @miohtama! Thanks for the suggestion, it is really appreciated.

The project owner should review your suggestion during the next week.

Please wait until we have discussed this idea before writing any code or submitting a Pull Request, so we can go through the design beforehand. We don’t want you to waste your time!

@ylv-io
Copy link
Contributor

ylv-io commented Apr 23, 2020

Hey @miohtama. Thanks a lot for putting this list together! I absolutely agree that better documentation is a key.

Asserting for tripped require()

Can you elaborate on that? I am no certain what is it about?

@miohtama
Copy link
Author

Basically how to check that the require() correctly failed and the message is correct.

expectEvent() and then the potential pitfalls of expectEvent().

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants