chavacava / chavacava.github.io

My notes on software development
0 stars 0 forks source link

2022/03/01/testing-is-bad #2

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

1 Testing is bad… | Monthly Notes on Programming

…,really bad, at checking your code does not have bugs. As our friend Edsger Dijkstra said:

https://chavacava.github.io/2022/03/01/testing-is-bad.html

sebagonz commented 2 years ago

I would automate the test of each variable instantiating them with a:

so taking into account that there are 3 of these variables, with 9 possible values. Then, the possible combinations to the extent are = 9^3 = 729.

chavacava commented 2 years ago

Hola @sebagonz, yes these are appropriate tests for the function. Even simple functions need a lot of use cases! Two remarks: 1) writing the 729 test cases will require a lot of time (even without discussing what "near to 0" means: 0,1 is near to zero? or 0,00000001?) Using techniques like fuzzing we will get better results than with manual definition of the cases. 2) What should the function return for the values 1000, 1, 2? (notice that with these segments we can not build a triangle) It is here where formal definitions shine. An English description of the function goal will always have ambiguities (a lot if the description is short and informal like the one I gave) On the other side, a formal description is written in a mathematical language that is designed to be unambiguous.

sebagonz commented 2 years ago

point noticed, and I guess if you wrote those formal definition on some languages similar to RSpec or Inspect to do a test driven development, well you could move define, test and develop on single junks of activities.