Beautiful TestsTests that are beautiful for their simplicity
Monday, October 21, 13
Binary Search
Monday, October 21, 13
The bug:
int mid = (low + high) / 2;
Solution:
int mid = low + ((high - low) / 2);
Show off:
int mid = (low + high) >>> 1;
Monday, October 21, 13
My initial testing strategy
Start with smoke tests.
Add some boundary value tests
Continue with various thorough and exhaustive types of tests
Finally, add some performance tests
Monday, October 21, 13
Smoking Allowed (and Encouraged)
These are designed to make sure that the code does the right thing when used in the most basic manner
Monday, October 21, 13
Smoking Allowed (and Encouraged)
“confidence maintenance”
Monday, October 21, 13
Pushing the Boundaries
Boundary testing is designed to explore and validate what happens when the code has to deal with extremes and corner cases
Monday, October 21, 13
Pushing the Boundaries
very large array ????
Monday, October 21, 13
Pushing the Boundaries
Monday, October 21, 13
Pushing the Boundaries
Monday, October 21, 13
Random Acts of Testing
A way to generate a large and diverse set of inputs
A set of generalized assertions that will work on any input
Monday, October 21, 13
Random Acts of Testing
Monday, October 21, 13
Performance Anxiety
Monday, October 21, 13
ConclusionUnit Tests allows you to make big changes to code quickly
Your tests give you confidence that you've done enough for now and can stop tweaking and move on to the next thing
Good unit tests can help document and define what something is supposed to do
Unit Tests help you really understand the design of the code you are working on
Monday, October 21, 13
Monday, October 21, 13
Top Related