knowledge how to write unit tests .Too busy projects .No test code in production code .Too much bother to write tests .Hard-to-Test Code .Unmaintainable test codes
projects . No test code in production code . Too much bother to write tests . Hard-to-Test Code . Unmaintainable test codes - Causes - - Possibly solutions - . Learn how to write tests . Improve project management . Legacy code improvement . Write the tests first . Testable code design . Tests with high readability and maintainability
projects . No test code in production code . Too much bother to write tests . Hard-to-Test Code . Unmaintainable test codes - Causes - - Possibly solutions - . Learn how to write tests . Improve project management . Legacy code improvement . Write the tests first . Testable code design . Tests with high readability and maintainability FOCUS ON
factor that makes it difficult to write complete, correct automated tests in a cost-effective manner.” Meszarosf, Gerard. xUnit Test Patterns: Refactoring Test Code / Chapter . Code Smells
smooth-sailing production code (in the middle of coding it) complete everything Testable design In the middle of coding, a programmer doesn’t take care testable design
code unless you first have a failing automated test Eliminate duplication TDD Rules https://www.eecs.yorku.ca/course_archive/ - /W/ /sectionM/case_studies/money/ KentBeck_TDD_byexample.pdf
.Run all tests, and fail .Make a little change .Run all tests and succeed .Refactor to remove duplication https://www.eecs.yorku.ca/course_archive/ - /W/ /sectionM/case_studies/money/ KentBeck_TDD_byexample.pdf
to remind us what all we need to do .Work on the TDD cycle • “Temporary implementation” for changing from red to green quickly • Add to-do you notices along the way
• Use separate code paragraphs for each of the As. • -As • Arrange: variable declaration and initialization • Act: invoking the code under test • Assert: verify that expectations • This pattern makes it easy to revisit test code https://integralpath.blogs.com/thinkingoutloud/ / /principles_of_t.html
projects . No test code in production code . Too much bother to write tests . Hard-to-Test Code . Unmaintainable test codes - Causes - - Possibly solutions - . Learn how to write tests . Improve project management . Legacy code improvement . Write the tests first . Testable code design . Tests with high readability and maintainability FOCUS ON
• Write test codes and production codes in TDD cycle • Write the tests first Programmer AFTER RED REFACT OR GREEN Write production codes Write test codes
is about feedback on the code’s internal qualities • ex. coupling cohesion of classes, dependencies, effective information hiding Freeman, Steve. Growing Object-Oriented Software, Guided by Tests Chapter . Listening to the Tests
the order page • Redirect when saving an order is succeeded • Calculate total amount of an order • Save order resource • Send charge request to external payment service • etc AFTER
• View the order page • Redirect when saving an order is succeeded • Calculate total amount of an order • Save order resource • Send charge request to external payment service • etc AFTER RED REFACT OR GREEN
page • Redirect when saving an order is succeeded • Calculate total amount of an order • Save order resource • Send charge request to external payment service • etc AFTER RED REFACT OR GREEN
highly cohesive, loosely coupled components, just to make testing easy” https://www.eecs.yorku.ca/course_archive/ - /W/ /sectionM/case_studies/money/ KentBeck_TDD_byexample.pdf A benefit of TDD
costly tests, however, is not to stop testing but instead to get better at it. Metz, Sandi. Practical Object-Oriented Design / Chapter Designing Cost-Effective Tests