bit of functionality you want to add. Write the functional code until the test passes. Refactor both new and old code to make it well structured. - Martin Fowler, “TestDrivenDevelopment”, https://martinfowler.com/bliki/TestDrivenDevelopment.html
avoid a lot of bad designs. It makes you think about the code you need to write, BEFORE you write it. 2. Once you have tests, they help you avoid introducing subtle bugs when you have to change the code later. Existing tests help prevent regressions in your code, where adding or changing one thing accidentally breaks another thing.
writing tests falls into one of two categories. “Here’s how to test a function that add two numbers. Now you can test anything. Good luck.” “You really should not be mocking your flux capacitor, but instead link the flibitz to the your cross-channel bit splicer.”
new things (YEAH! TESTS!) 3. Velocity slows because TDD does take more time up-front 4. “We’re not going to meet this deadline ?!?” (STOP DOING TDD) 5. As tests age, skip them or ignore failing tests (PEOPLE IGNORE TESTS) Start TDD Deadlines ?!? Graveyard of Tests
tests, you have to wait: first for the entire product to be built, then for it to be deployed, and finally for all end-to-end tests to run. When the tests do run, flaky tests tend to be a fact of life. And even if a test finds a bug, that bug could be anywhere in the product. Although end-to-end tests do a better job of simulating real user scenarios, this advantage quickly becomes outweighed by all the disadvantages of the end-to-end feedback loop. — https://testing.googleblog.com/2015/04/just-say-no-to-more-end-to-end-tests.html Unit vs. Functional Tests
a string with the remaining minutes and seconds. 1. Both times will be JavaScript Date object. 2. The current time will never be more than 1 hour before the end time, but may be the same or after. 3. The remaining time should always have 2 digits for both minutes and seconds, even if they are less than 10. Let’s TDD a function
currentTimestamp = currentTime.getTime(); const totalSecondsRemaining = ((stopTimestamp - currentTimestamp) / 1000); return `00:${totalSecondsRemaining}`; } Make the second test pass
is the same as the current time'); ^ Error: should return no time if end time is the same as the current time at Object.<anonymous> (/Users/vwilson/Projects/ personal/javascript/countdown/test.js:2:9) Oooooop! Now the first test breaks! It returns 00:0