20
lorentz
3y

I just wrote 80+ lines of tests for a 30 line module and I was really mad at myself for wasting my time like that, until I remembered that while writing those tests I did actually catch several really tricky bugs and it didn't even take that long.

Comments
  • 1
    My test files can sometimes go into the thousands of lines for relatively small modules, no shame in that :D
  • 0
    Can’t you create smaller test cases?
  • 1
    @aviophile The test cases are tiny, but I need a lot of them to test various combinations of flags that substantially change the behavior of the function.
  • 0
    As test code is all about being written in the most simplest way imaginable and has to be pretty explicit for that reason, there is nothing wrong with having multiple lines for each single case. And needing more than ten cases for testing a single simple invariant is pretty common.
    So testing a single function with hundreds of lines isn't neccessarily a bad thing.
  • 0
    Hey, did you know that if you pass a promise to the resolve function of a promise it'll derive its state from that of the argument, whereas if you pass it to reject the result will be rejection with the promise as the error object?
    Because I sure as fuck didn't, and this asymmetry just cost me two days.
Add Comment