130 likes | 142 Views
Session 20. Debriefing HW3 Testing HW3. What I looked for in BoundedInteger. Did it compile and run with your tester? Did it compile with my tester (did it conform to the specs)? Did you provide all EXPLICIT requirements? Did you provide all IMPLICIT requirements?.
E N D
Session 20 Debriefing HW3 Testing HW3
What I looked for in BoundedInteger • Did it compile and run with your tester? • Did it compile with my tester (did it conform to the specs)? • Did you provide all EXPLICIT requirements? • Did you provide all IMPLICIT requirements?
What do I mean by implicit requirements?? • Will addition and subtraction handle all int values of input? • “Large” • Negative • Will the code work with non-zero lower bounds?
Other things in BoundedInteger • IVS are private • No extra IVs • Reasonable style • Using helper methods? • Constructors? • setValue() uses isLegal() • equals() uses equivalentX() • add() uses increment() or vice versa • Using logic appropriately • Don’t put ifs in methods that return boolean values. • Boolean versus boolean
Access methods and the “same” class • Several of you wrote code that said: if (this.getLowerLimit() == other.getLowerLimit() … • But you actually CAN say: if (this.lowerLimit == other.lowerLimit … • Why doesn’t this violate the principle of “private”
What I looked for in your tester • Did you name it correctly? • Test both constructors? • Test all fourteen methods? • Did you REALLY test all methods? • Note: How YOU test maybe different from how _I_ would test (whitebox versus blackbox testing).
Testing Thoughts • Constructors • Valid bounds, valid start • Valid bounds, invalid start • Valid bounds, no start • Invalid bounds, “valid” start • Invalid bounds, “invalid” start • Invalid bounds, no start • Furthermore, at least ONE attempt to make an instance with negatives involved
Testing Thoughts • Mathematical operators • Add/Sub positive number with no roll over. • Add/Sub positive numbers with “just” roll over. • Add/Sub positive numbers with significant roll over. • Add/Sub positive numbers with “double” roll over. • Test some of the above with different lower limits (make sure it isn’t a fluke) • Repeat all of above with negative number inputs.
Testing • Accessors (getValue, toString) • PROBABLY only need to test each method once since WHAT they do isn’t state dependent. • Mutator (setValue) • Probably want to fence post (both sides of both limits) • You need to test BOTH pieces of functionality (modification and return value)
Testing • Comparison operators (black/white issue again) • Equals (technically eight combinations to test) • Same value, same upper, same lower • Same value, same upper, different lower • Same value, different upper, same lower • Same value, different upper, different lower • Different value, same upper, same lower • Different value, same upper, different lower • Different value, different upper, same lower • Different value, different upper, different lower
Testing • Comparison operators (black/white issue again) • Equivalent Value • Technically we only need to look at Same/Diff value • But I actually tested all eight cases from above • Equivalent Limits • Similar here. • isValid • Fenceposting again
A “larger” problem that most of you didn’t think about • What happens if either or both bounds are close to the actual bounds of an int??? BoundedInteger bi=new BoundedInteger(0,Integer.MAX_VALUE) bi.add(Integer.MAX_VALUE); bi.add(3);
Exam #1 on Wednesday • Based on lectures and readings • Based on CONCEPTS and not code writing • Understand vocabulary • Be able to explain the basic concepts of the course so far