Software Engineering I Notes Sept 9, 2013 Black box Don't know what's going on inside code Can't see source code or internal data White/glass box Can see code Can do more analysis Can attempt to ensure certain coverage of statements E.g. 90 % of all statements executed 80% of all branches taken White box strategies Cover all possible paths Infeasible Cover all possible edges Design a pattern to make sure all outgoing nodes of a flowchart Could test all values Impossible! Equivalence clases Divide possible inputs into groups that can be treated the same One test per eq class Month validation Vehicle information Units Maximum/minimum speed Fule types Fuel efficiency time to accelerate Range Boundary testing Defects Incorrect logical conditions Logic condition for if-then-else/loop is incorrectly formed e.g. use and instead of or < instead of > >= instead of > Parentheses in wrong place See Storn's Chebyshev function Perf. calc in wrong part of control construct while(j < maximum) { k = someOp(j) j++ } if(k == -1) s.o.pl("Error in computation") Use equivalence class and boundary testing Execute loops zero, 1, and more than one times Not terminating a loop i = 0; j = N; while( i < j) doSomething() Not setting up correct preconditions test all preconditions, esp values beyond what algorithm can expect Not handling null conditions Find all null conditions possible and run test cases Singleton/non singleton More than one or only one of something Testing strategies may need brainstorming What if you are recoding someone's program from C into Java What if there was an expectation that there was only one global representing what is now a object? Off-by-one errors for(int i = 1; i < arrayName.length; i++) doOperation(arrayName[i]); Use boundary testing!!! Operator precedence errors x +( y * z) vs (x+y)*z x*y/z what if they are integers? Is (x*y)/z == x*y/z? what about y/z*x? Using wrong standard algorithms inefficient sorting examples? insertion sort vs quicksort vs mergesort inefficient search algorithm binary search vs linear search Unstable sorting algorithms Defects in numerical algorithms Not enough precision short vs int vs long float vs double BigNumber What if you are building a bridge and it ends up misaligned because of improper precision what if you can't support large enough numbers? Poor order of operations 3.78*10^24 + 1 Floating point comparisons with equality is 10.0 == 9.9999999999999? is 10.0 = (2.0+2.0+2.0+2.0+2.0) ? Are these valid comparisons? NO! Using two double values, x and y compare as follows: abs(x - y) < 1e-16