870 reputation
516
bio website
location
age
visits member for 3 years, 10 months
seen Aug 18 at 9:22

Jun
27
comment How should I test boolean function with many possible permutations
I usually test private methods with introspection, but this is a controversial topic. Have a look here: stackoverflow.com/questions/34571/…
Jun
27
revised How should I test boolean function with many possible permutations
added 879 characters in body
Jun
27
accepted How should I test boolean function with many possible permutations
Jun
27
comment How should I test boolean function with many possible permutations
So if you need to test the output of a method that takes 3 boolean parameters, you will test every possible combination ? And what if one of the parameters is a not boolean and the amount of possible combination explodes ?
Jun
27
comment How should I test boolean function with many possible permutations
a) this is an example; not real case; but often boolean expression are quite complex, even when reduced with intermediate steps: it' a bit like regular expression. b) I'm concerned when the test is more verbose and more complicated than the tested code: first it is a nightmare to maintain, and where are the tests for the tests then ?
Jun
27
revised How should I test boolean function with many possible permutations
added 368 characters in body
Jun
27
comment How should I test boolean function with many possible permutations
Yes, refactoring is the natural way to go. By the way my example was awful on purpose: it's the kind of code I'll found in my 'back to future' project. But sometime the expression is not so simple to decompose, or it belongs in external codebase that is not tested... Another point is that intermediate methods should be private, hence they should no be unit tested; and the permutation issue would stay the same. I would also prefer to have intermediate variables than intermediate methods for small bit like this, especially if the class contains already many methods.
Jun
27
comment How should I test boolean function with many possible permutations
I started to consider this option after having some trouble to write tests for heavy boolean expression. I considered the refactoring approach as suggested by MainMa, but then I considered truth tables (and generator for the parameter combinations). I asked the question here because I wanted to have hints from others before going to deep in this solution.
Jun
27
revised How should I test boolean function with many possible permutations
added 121 characters in body
Jun
27
revised How should I test boolean function with many possible permutations
added 112 characters in body
Jun
27
asked How should I test boolean function with many possible permutations
May
12
awarded  Popular Question
Feb
24
awarded  Nice Answer
Jan
26
comment Code maintenance: keeping a bad pattern when extending new code for being consistent, or not?
Hi Erik, sometimes a code that could have been factorized is more simpler to read: it is dozen of time the same thing and the code is straightforward. You can read it in a row without to think about it and you can debug in a linear way. There is no hidden complexity.
Jan
15
awarded  Popular Question
Oct
11
awarded  Yearling
Jun
7
awarded  Enlightened
Jun
7
awarded  Nice Answer
May
20
awarded  Popular Question
Feb
20
awarded  Caucus