Coding Blocks | Software and Web Programming / Security / Best Practices / Microsoft .NET
Technology:Software How-To
Episode 54 – Clean Code – How to Write Amazing Unit Tests
When and why should you write unit tests, and just how important are they? Take a listen and see what YOU think.
#yop-poll-container-31_yp593f59cc11fd9 { width: 1000; background:#fff; padding:10px; color:#555; overflow:hidden; font-size:12px; } #yop-poll-container-31_yp593f59cc11fd9 input[type='text'] { margin:0px 0px 5px 0px; padding:2%; width:96%; text-indent:2%; font-size:12px; } .yop-poll-name-31_yp593f59cc11fd9 { font-weight:bold; background:#327BD6; color:#fff; padding:5px; text-align:center; font-size:12px; } #yop-poll-questions-container-31_yp593f59cc11fd9 { font-size:14px; margin:5px 0px; } .yop-poll-question-container-31_yp593f59cc11fd9 { padding: 2px; } .yop-poll-question-31_yp593f59cc11fd9 { background:#327BD6; color:#fff; margin-bottom: 21px; margin-top: -10px; font-style: italic; text-align: center; width: 100%; padding:5px; } .yop-poll-answers-31_yp593f59cc11fd9 { } .yop-poll-answers-31_yp593f59cc11fd9 ul { list-style: none outside none; margin: 0; padding: 0; } .yop-poll-li-answer-31_yp593f59cc11fd9 { font-style:normal; margin:0px 0px 10px 0px; padding:0px; font-size:12px; margin-bottom:20px; } .yop-poll-li-answer-31_yp593f59cc11fd9 input { margin:0px; float:none; } .yop-poll-li-answer-31_yp593f59cc11fd9 label { margin:0px; font-style:normal; font-weight:normal; font-size:12px; float:none; } .yop-poll-results-31_yp593f59cc11fd9 { font-size: 12px; font-style: italic; font-weight: normal; margin-left: 15px; } .yop-poll-customs-31_yp593f59cc11fd9 { } .yop-poll-customs-31_yp593f59cc11fd9 ul { list-style: none outside none; margin: 0; padding: 0; } .yop-poll-li-custom-31_yp593f59cc11fd9 { padding:0px; margin:0px; font-size:14px; } /* Start CAPTCHA div style*/ #yop-poll-captcha-input-div-31_yp593f59cc11fd9 { margin-top:5px; } #yop-poll-captcha-helpers-div-31_yp593f59cc11fd9 { width:30px; float:left; margin-left:5px; height:0px; } #yop-poll-captcha-helpers-div-31_yp593f59cc11fd9 img { margin-bottom:2px; } #yop-poll-captcha-image-div-31_yp593f59cc11fd9 { margin-bottom:5px; } #yop_poll_captcha_image_31_yp593f59cc11fd9 { float:left; } /* End CAPTCHA div style*/ .yop-poll-clear-31_yp593f59cc11fd9 { clear:both; } #yop-poll-vote-31_yp593f59cc11fd9 { } /* Start Result bar*/ .yop-poll-results-bar-31_yp593f59cc11fd9 { background:#f5f5f5; height:10px; } .yop-poll-results-bar-31_yp593f59cc11fd9 div { background:#555; height:10px; } /* End Result bar*/ /* Start Vote Button*/ #yop-poll-vote-31_yp593f59cc11fd9 div#yop-poll-vote-31_yp593f59cc11fd9 button { float:left; } #yop-poll-vote-31_yp593f59cc11fd9 div#yop-poll-results-31_yp593f59cc11fd9 { float: right; margin-bottom: 20px; margin-top: -20px; width: auto; } #yop-poll-vote-31_yp593f59cc11fd9 div#yop-poll-results-31_yp593f59cc11fd9 a { color:#fff; text-decoration:underline; font-size:12px; } #yop-poll-vote-31_yp593f59cc11fd9 div#yop-poll-back-31_yp593f59cc11fd9 a { color:#555; text-decoration:underline; font-size:12px; } #yop-poll-vote-31_yp593f59cc11fd9 div#yop-poll-archive-31_yp593f59cc11fd9 a { color:#555; text-decoration:underline; font-size:12px; } #yop-poll-vote-31_yp593f59cc11fd9 div { float:left; width:100%; } /* End Vote Button*/ /* Start Messages*/ #yop-poll-container-error-31_yp593f59cc11fd9 { font-size:12px; font-style:italic; color:red; text-transform:lowercase; margin-bottom:20px; text-align:center; } #yop-poll-container-success-31_yp593f59cc11fd9 { font-size:12px; font-style:italic; color:green; margin-bottom:20px; text-align:center; } /* End Messages*/#yop-poll-container-31_yp593f59cc11fd9 img { max-width: 1000; } .yop-poll-forms-display{}iTunes: AUS Dan G, bryangrove, Criviere, Kasprs, sulhogar, Niil Ohlin (Neil Ilin)
Stitcher Reviews: indiegamer21, makeACaseForCamelCase, athyng, brokenrelay, El_Zilcho
MongoDb and ElasticSearch Ransomware Attacks
http://www.pcworld.com/article/3157417/security/after-mongodb-ransomware-groups-hit-exposed-elasticsearch-clusters.html
Alexa 7 Minute Workout
https://www.amazon.com/Pargee-7-Minute-Workout/dp/B018WUNBE6
Question: Does every programmer spend their nights coding?!
Send us a SASE – http://www.codingblocks.net/swag
Winner of Clean Code for Episode 52
Kevin Kemier – @kevinkemler
Thanks for the post cards from Wroclaw and Gdansk, Poland Rocks!
Community Spotlight: http://www.codingblocks.net/community-spotlight/
Advice for new programmers? Make something fun and launch!
Mini Code Adventures:
Problem with this approach – test code could outgrow your prod code and become unmanageable
Is dirty test code better than no test code?
Abandoning test code has the following consequences
Test code is as important as production code – it should be treated as a first class citizen and should be as clean as production code.
Tests Enable the -ilitiesWithout tests, your code base rots.
Clean TestsMuch like writing great functions, if you have to learn a ton of details to make heads or tails of a test, it can be improved.
Build – Operate – Check PatternBuild – builds up the test data
Operate – works on the test data
Check – ensure the operation yielded the expected results
Great example in the book of refactoring an ugly test to a clean one
Domain Specific Testing LanguageInteresting points made on asserts in line with values…
Author chose to do upper / lower combination of characters in an initialism to indicate whether the particular test result should have been true or false
Unit tests are often not held to the same standard in terms of performance
More important than a single assert per test
Ensures that your tests are laser focused and not testing miscellaenous (non-related) things
Unit Tests are as important if not moreso than the production code they’re for becasue they allow you to make changes confidently and without fear. They allow you to mold your code over time to improve flexibility / maintainability.
Resources we Like
Create your
podcast in
minutes
It is Free