kleros / kleros-interaction

Smart contracts able to interact with Kleros
MIT License
87 stars 62 forks source link

DRY (don't repeat yourself) when writing tests #255

Closed marsrobertson closed 5 years ago

marsrobertson commented 5 years ago

https://github.com/kleros/kleros-interaction/blob/master/test/multiple-arbitrable-transaction.js

Repeated 26 times:

const lastTransaction = await getLastTransaction

This surely can be extracted as an individual function?

Or use beforeEach block?

clesaege commented 5 years ago

Redundancy and repeating in tests is fine. Tests should be the less abstact possible.

marsrobertson commented 5 years ago

image

The code is repeated so many times.

  1. Is each of the functions exactly the same?

  2. It's more lines, more things to analyze.

clesaege commented 5 years ago

Yeah, it makes it harder to miss something when writing it. You don't need to analyse tests, if you want more security you can make other ones as tests handles redundancy well.