2 ms·
> Twice as much code in unit tests than prod code Easily. Sometimes more, depending on the complexity. I had a configuration file generator with 5x as many lin
by outworlder 6y ago
> Twice as much code in unit tests than prod code
Easily. Sometimes more, depending on the complexity. I had a configuration file generator with 5x as many lines of code being testing code. The consequences of getting even one field wrong would be severe, if they made to production undetected. There was some hairy legacy logic that I had to emulate.
The thing is, you need to test all your corner cases. These are more important in unit tests.
If the code is simple then you will be able to get away with much less. Every branch you add increases the complexity a lot.
- ensiferum 6y agoI've found the same. Unit tests easily have 3-5x the code that is being tested. But most of the code is very very straightforward with little complexity. I.e call this method with N different arguments covering edge cases border values illegal values and legal values. Example https://github.com/ensisoft/newsflash-plus/blob/master/engine/unit_test/unit_test_session.cpp https://github.com/ensisoft/newsflash-plus/blob/master/engin...