Unit Testing, TDD, and More
About the Course
Product quality, code quality, and time to market can all be improved and optimized through effective use of unit tests. Testing in small, isolated, and deterministic units fosters code characteristics such as testability, adaptability, and reliability. This testing strategy shifts failures towards the left of our SDLC and greatly reduces development time, costs, and risks.
This course teaches the principles and practices of unit testing, along with core techniques for writing testable software and avoiding test smells. Dependency Inversion is taught as an effective method for isolating the system under test, along with test doubles for overriding behavior, further enhancing testability.
The principles and practices of Test-Driven Development (TDD) are also taught and demonstrated to show how proper software design evolves through application of the eXtreme Programming principle of Test First. An application is developed (from start to finish) during this course to explain step-by-step and demonstrate first-hand how a high quality, loosely-coupled design evolves by applying the three laws of Test-Driven Development.
The following topics provide the foundation, strategies, and techniques for building good unit tests which enable agility, along with the capability for continuous delivery.
Test Automation Pyramid
The test automation pyramid is discussed as a testing strategy that effectively supports Agile development and DevOps models for continuous delivery. This concept was introduced in 2009 by Mike Cohn in his book Succeeding with Agile and is often referenced by leaders such as Martin Fowler, Ward Cunningham, and Bob Martin. It provides context as to how unit tests relate to other types of testing efforts. This helps to ensure the right amount of testing within the various scopes of architecture while minimizing test overlap.
Basics of Unit Testing
Basic unit testing skills are explained and demonstrated to show how to structure unit tests, to examine best practices for building test fixtures, and to show the differences between good unit tests and bad ones.
This course examines 12 unit testing techniques that establish a foundation for writing tests that support agility and enable continuous delivery through a reliable and trusted test suite.
Avoiding Test Smells
Numerous red flags often appear at the project level, within tests, and within production code that indicate problems related to testing. Methods of identifying the root cause and removing these smells are discussed in detail.
Making Code Testable
Writing good tests quickly with effective code coverages depends greatly on the testability of the code. Several software engineering principles are reviewed (at a high level) as methods to enhancing software testability — making it easy to test and discover bugs.
Understanding Test Doubles
Effective and dependable unit testing relies greatly on the ability to isolate internal and external dependencies. Utilizing test doubles is discussed as an effective method for overriding behavior of production resources, further enhancing testability.
Accelerating Software Delivery
High quality, loosely-coupled and highly cohesive code evolves from the application of the eXtreme Programming principle of Test First. While optimizing both, TDD is about building code quality as much as building code coverage. The practices of TDD are taught in detail.
The Three Laws of TDD
The three laws of Test-Driven Development define the discipline of TDD. By following these three laws, your software will organically evolve into one that is maintainable, extensible, and testable.
Transforming to Green
How you write the code to make your tests pass can result in a good architecture or one that works, but could be much better. Applying a prioritized set of transformations can make all the difference in building a great solution.
TDD vs ATDD
While many confuse the practice of ATDD with TDD, these two approaches to development are very different. As these are separate and distinct practices, the methods of each are explained to clarify their unique value, followed by a side-by-side comparison.
TDD by Example
An application is developed (from start to finish) to explain step-by-step and demonstrate first-hand how a high quality, testable design evolves by applying the three laws of Test-Driven Development.