Beatiful tests

594 views

Published on

Code is typically considered beautiful if it does what it's supposed to do with unique elegance and economic.
Tests can also be beautiful themselves.
More importantly, they can play a key role in helping you create more beautiful code.

From Nguyen Hoang Viet - Asskicker at Silicon Straits Saigon

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
594
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Beatiful tests

  1. 1. Beautiful Tests Tests that are beautiful for their simplicity Monday, October 21, 13
  2. 2. Binary Search Monday, October 21, 13
  3. 3. 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
  4. 4. 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
  5. 5. 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
  6. 6. Smoking Allowed (and Encouraged) “confidence maintenance” Monday, October 21, 13
  7. 7. 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
  8. 8. Pushing the Boundaries very large array ???? Monday, October 21, 13
  9. 9. Pushing the Boundaries Monday, October 21, 13
  10. 10. Pushing the Boundaries Monday, October 21, 13
  11. 11. 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
  12. 12. Random Acts of Testing Monday, October 21, 13
  13. 13. Performance Anxiety Monday, October 21, 13
  14. 14. Conclusion Unit 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
  15. 15. Monday, October 21, 13

×